From 259ce7a18a3f5f0343e64d053374bb9f3bd7046e Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Thu, 30 May 2024 10:58:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YuMi.xcodeproj/project.pbxproj | 6 + .../Contents.json | 22 - .../ms_room_game_underwa_top_icon@2x.png | Bin 6857 -> 0 bytes .../ms_room_game_underwa_top_icon@3x.png | Bin 12091 -> 0 bytes .../Modules/YMMessage/Model/AttachmentModel.h | 10 + .../YMNewHome/Model/HomePlayRoomModel.h | 2 +- .../View/RoomGame/Api/Api+MSRoomGameApi.h | 2 + .../View/RoomGame/Api/Api+MSRoomGameApi.m | 4 + .../View/RoomGame/Model/MSRoomGameModel.h | 56 + .../View/RoomGame/Model/MSRoomGameModel.m | 22 + .../RoomGame/Presenter/MSRoomGamePresenter.h | 8 +- .../RoomGame/Presenter/MSRoomGamePresenter.m | 54 + .../RoomGame/Protocol/MSRoomGameProtocol.h | 2 + .../YMRoom/View/RoomGame/View/MSRoomGameVC.h | 6 +- .../YMRoom/View/RoomGame/View/MSRoomGameVC.m | 121 +- .../View/RoomGame/View/MSTabbarRoomGameVC.m | 18 +- .../View/SubView/MSRoomGameHeadAvatarView.h | 2 +- .../View/SubView/MSRoomGameHeadAvatarView.m | 4 + .../View/SubView/MSRoomGameHeadView.h | 5 +- .../View/SubView/MSRoomGameHeadView.m | 40 +- .../RoomGame/View/SubView/MSRoomGameMsgView.h | 5 +- .../RoomGame/View/SubView/MSRoomGameMsgView.m | 58 +- .../RoomGame/View/SubView/MSRoomGameView.m | 1630 ++++++++--------- YuMi/zh-Hans.lproj/Localizable.strings | 7 + YuMi/zh-Hant.lproj/Localizable.strings | 9 +- 25 files changed, 1164 insertions(+), 929 deletions(-) delete mode 100644 YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/Contents.json delete mode 100644 YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/ms_room_game_underwa_top_icon@2x.png delete mode 100644 YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/ms_room_game_underwa_top_icon@3x.png create mode 100644 YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.h create mode 100644 YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.m diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index 965adc66..868e16ef 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -288,6 +288,7 @@ 237701102BCF740400D661F1 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 2377010F2BCF740400D661F1 /* libsqlite3.tbd */; }; 237701122BCF742C00D661F1 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 237701112BCF742C00D661F1 /* libz.tbd */; }; 237701192BD6143700D661F1 /* pi_happy_egg_smash.svga in Resources */ = {isa = PBXBuildFile; fileRef = 237701182BD6143700D661F1 /* pi_happy_egg_smash.svga */; }; + 237852A12C072D8D00E360AC /* MSRoomGameModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A02C072D8D00E360AC /* MSRoomGameModel.m */; }; 237B94BC2A984DA7007853E3 /* XPTrumpetPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */; }; 237B94BD2A984DA7007853E3 /* XPNobleTrumpetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B32A984DA7007853E3 /* XPNobleTrumpetModel.m */; }; 237B94BE2A984DA7007853E3 /* XPRoomTrumpetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B72A984DA7007853E3 /* XPRoomTrumpetViewController.m */; }; @@ -2107,6 +2108,8 @@ 2377010F2BCF740400D661F1 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; }; 237701112BCF742C00D661F1 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 237701182BD6143700D661F1 /* pi_happy_egg_smash.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_happy_egg_smash.svga; sourceTree = ""; }; + 2378529F2C072D8D00E360AC /* MSRoomGameModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSRoomGameModel.h; sourceTree = ""; }; + 237852A02C072D8D00E360AC /* MSRoomGameModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRoomGameModel.m; sourceTree = ""; }; 237B94AD2A984DA7007853E3 /* XPTrumpetPresenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPTrumpetPresenter.h; sourceTree = ""; }; 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPTrumpetPresenter.m; sourceTree = ""; }; 237B94B02A984DA7007853E3 /* XPRoomTrumpetProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPRoomTrumpetProtocol.h; sourceTree = ""; }; @@ -6058,6 +6061,8 @@ children = ( 239D0FD62C047DD8002977CE /* MSTabbarRoomGameModel.h */, 239D0FD72C047DD8002977CE /* MSTabbarRoomGameModel.m */, + 2378529F2C072D8D00E360AC /* MSRoomGameModel.h */, + 237852A02C072D8D00E360AC /* MSRoomGameModel.m */, ); path = Model; sourceTree = ""; @@ -11831,6 +11836,7 @@ E81060EB2987BE8300B772F0 /* MessageGiftModel.m in Sources */, E8EEB91726FC7B35007C6EBA /* XPMineUserInfoDesViewController.m in Sources */, 9B1B72AC280031DB003FACE9 /* XPAnchorPKViewController.m in Sources */, + 237852A12C072D8D00E360AC /* MSRoomGameModel.m in Sources */, 180806FB2729A354001FD836 /* ThemeColor+Room.m in Sources */, 9BC8C83028090C9200C24F85 /* XPRoomAnchorRankBannerView.m in Sources */, E81A653F283511BE00F55894 /* XPMonentsInteractiveViewController.m in Sources */, diff --git a/YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/Contents.json b/YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/Contents.json deleted file mode 100644 index 0f4a220d..00000000 --- a/YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/Contents.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, - { - "filename" : "ms_room_game_underwa_top_icon@2x.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "ms_room_game_underwa_top_icon@3x.png", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/ms_room_game_underwa_top_icon@2x.png b/YuMi/Assets.xcassets/RoomGame/ms_room_game_underwa_top_icon.imageset/ms_room_game_underwa_top_icon@2x.png deleted file mode 100644 index 000e7da97935433dc099a71acd477f20f050e121..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6857 zcmV;)8aCyLP)h00090P)t-s00015 z4FFpV09p+ISq%W(*Vn#?JYt-dWl1HtXKrAz!iLM!L$%de4FLO{3tt!ngi;=3&D~lI z0C|v;^U6C|yE9r10OsMETMqz(tjJpp0EjXcgwWSskGuBNOyH3o*5S(pKAx9sS={Q# z(8gF=4FF=sH|N`T^VMAW+-ByHB}RtFu4gdm!$O8=WY&TZS`7fr=BC1somsp)Tg@nd zx`?!YLuAZ9y}M24pBh>X09p+I{`-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zt0FxKmswP5LZ$xD^YOvv>~uNZ}DSSvDfP&A_CD4c0cbyM6#n;*ij62a1I4C zF?r63TOdTIcu&E+lEQ*3;kD)RED(8GcKGRgN_EI0+ueZ>?Py7)nb^_eh_M~Gh3&ux zhsl|??{OvU3dFO-=ZoC+4`LRuNPevnE13+bR3y;AP2fv*1eFAnU+ye$YxibzHq=(^O4EH&i-XUmo7qR`7qV(WNUKDQu(>=#jHSlN|?jz+11oq0y$YqsLo1ARK-PDlqOjW~yZ+ zS{HgziKpy+N}(-GVvtlhpI1b-y90O{>=Lw}zNSZ<(igC7&Svxu_(x?SX>&X@J!6xknb+><-Xb+CfLVMwt8H#^Y0? zGM-=24ovEEWXIiTf`PAQ`~!`pw170Dng*C#l}xV0dW_zX0|#6Dq8;JHj(mia+B?yN z?m_Wp$Q}BU>~KXQsjQk_10Y5CejFdILh^wA?zpXS%%^1rU#`U8aWvzc6f<7$4%1HV zbyLI#&vBPDP1AO?fewL_vjcGjk-js);sjFV(}RWE5HL?GnDk6FFbTd?Nv1QQk`PYp zHb_6u3$H6{BHP`O0doYbVQ;5X5Bq|^@TV%H(-#9sDz z|EfDYe{a*j_w#7SlfGt0ops+ICD4>NeZwiQT2oKS#}*Y*QQ^Mx}&!K&@*dJycAN}%#PQ6(bh8y(ie zIDt;u+ae;c+EM_H;x}6J{Lx+kZGsmiJPpdm=i`xNMP}&*POwUTfZ&g0;6`GG1lh0{ zzB0RR91BLSy36#wRWv4a2r002ovPDHLkV1kJ2L7V^p diff --git a/YuMi/Modules/YMMessage/Model/AttachmentModel.h b/YuMi/Modules/YMMessage/Model/AttachmentModel.h index d2b27956..c9a50cef 100644 --- a/YuMi/Modules/YMMessage/Model/AttachmentModel.h +++ b/YuMi/Modules/YMMessage/Model/AttachmentModel.h @@ -122,6 +122,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) { CustomMessageType_General_Floating_Screen = 107, ///聊天大厅上头条 CustomMessageType_Chat_Hall_Headlinesn = 108, + ///游戏 + CustomMessageType_Chat_Room_Game = 109, ///家族新协议 CustomMessageType_New_Hall = 110, }; @@ -663,6 +665,14 @@ typedef NS_ENUM(NSUInteger, CustomMessageTypeChatHallHeadlinesn) { ///所有房间 Custom_Message_Sub_Chat_Hall_Headlinesn = 1081,//单房间 +}; +//CustomMessageType_Chat_Room_Game = 109, +typedef NS_ENUM(NSUInteger, CustomMessageTypeRoomGame) { + + Custom_Message_Sub_Room_Game_Match_Success = 1091,//匹配成功 + Custom_Message_Sub_Room_Game_Match_Fail = 1092,//匹配失败 + + }; ///家族新协议 //CustomMessageType_New_Hall = 110, diff --git a/YuMi/Modules/YMNewHome/Model/HomePlayRoomModel.h b/YuMi/Modules/YMNewHome/Model/HomePlayRoomModel.h index 73d1f79b..a3565489 100644 --- a/YuMi/Modules/YMNewHome/Model/HomePlayRoomModel.h +++ b/YuMi/Modules/YMNewHome/Model/HomePlayRoomModel.h @@ -78,7 +78,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,copy) NSString *nick; ///用户的uid @property (nonatomic,copy) NSString *uid; - +@property(nonatomic,copy) NSString *erbanNo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h index d2aa38d8..71b51f05 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h @@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN +(void)getRoomGameHomeConfig:(HttpRequestHelperCompletion)completion; ///开始匹配游戏 +(void)startMatchGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode; +///得到房间详情 ++(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m index c2133871..93c6653d 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m @@ -16,4 +16,8 @@ +(void)startMatchGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode{ [self makeRequest:@"miniGame/nav/start" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,roomId,mgId,gameMode,nil]; } +///得到房间详情 ++(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType{ + [self makeRequest:@"chatRoom/getByType" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,roomType,nil]; +} @end diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.h b/YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.h new file mode 100644 index 00000000..6dbac76f --- /dev/null +++ b/YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.h @@ -0,0 +1,56 @@ +// +// MSRoomGameModel.h +// YuMi +// +// Created by duoban on 2024/5/29. +// + +#import "PIBaseModel.h" +#import "HomePlayRoomModel.h" +NS_ASSUME_NONNULL_BEGIN + + +typedef enum : NSUInteger { + MSRoomGameInfoModelMatchmaking,// 匹配中 + MSRoomGameInfoModelMatchSuccessfully,//匹配成功 + MSRoomGameInfoModelGameEnd,///游戏结束 + MSRoomGameInfoModelMatchFail ,/// 匹配失败 +} MSRoomGameInfoModelType; + + + + +@class MSRoomGameMicModel,MSRoomGameInfoModel; +@interface MSRoomGameModel : PIBaseModel +@property(nonatomic,strong) MSRoomGameInfoModel *data; +@property(nonatomic,assign) int roomType; +@property(nonatomic,copy)NSString *chatRoomId; +@property(nonatomic,copy) NSString *roomId; +@property(nonatomic,copy) NSArray *roomMics; +@end + + +@interface MSRoomGameMicModel : PIBaseModel + +@property(nonatomic,assign)BOOL micState; +@property(nonatomic,copy) NSString *roomId; +@property(nonatomic,strong) HomePlayMicUserModel *micUser; +@property(nonatomic,assign) int posState; +@property(nonatomic,assign) int position; +@end + +@interface MSRoomGameInfoModel : PIBaseModel +@property(nonatomic,copy) NSString *gameRoomIcon; +@property(nonatomic,copy) NSString *mgId; +//"轮次状态 0 进行中 1 结束 +@property(nonatomic,assign) int roundStatus; +///结果分值 +@property(nonatomic,copy) NSArray *scores; +@property(nonatomic,copy) NSString *configJson; +@property(nonatomic,assign) MSRoomGameInfoModelType matchStatus; + + + +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.m b/YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.m new file mode 100644 index 00000000..8856fb85 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/RoomGame/Model/MSRoomGameModel.m @@ -0,0 +1,22 @@ +// +// MSRoomGameModel.m +// YuMi +// +// Created by duoban on 2024/5/29. +// + +#import "MSRoomGameModel.h" + +@implementation MSRoomGameModel ++ (NSDictionary *)objectClassInArray{ + return @{@"roomMics":MSRoomGameMicModel.class}; +} +@end + +@implementation MSRoomGameMicModel + +@end +@implementation MSRoomGameInfoModel + +@end + diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.h b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.h index 59697b39..168eff2c 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.h @@ -6,7 +6,7 @@ // #import "BaseMvpPresenter.h" - +#import "UserInfoModel.h" NS_ASSUME_NONNULL_BEGIN @interface MSRoomGamePresenter : BaseMvpPresenter @@ -14,6 +14,12 @@ NS_ASSUME_NONNULL_BEGIN -(void)getRoomGameConfig; ///开始匹配游戏 -(void)startMatchGameWithroomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode; +///得到房间详情 +-(void)getRoomGameDetailWithRoomType:(NSString *)roomType; +///进入房间 +- (void)enterNIMRoom:(NSString *)roomId user:(UserInfoModel *)userInfo; +///退出房间 +- (void)exitNIMRoom:(NSString *)roomId; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m index 0066d2e1..736b603c 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m @@ -13,6 +13,9 @@ #import "WalletInfoModel.h" #import "MSTabbarRoomGameModel.h" #import "MSRoomGameProtocol.h" +#import "MSRoomGameModel.h" +#import +#import "XPMessageRemoteExtModel.h" @implementation MSRoomGamePresenter -(void)getRoomGameConfig{ @@ -64,4 +67,55 @@ } showLoading:YES errorToast:YES] roomId:roomId mgId:mgId gameMode:gameMode]; } +///得到房间详情 +-(void)getRoomGameDetailWithRoomType:(NSString *)roomType{ + [Api getRoomGameDetails:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + MSRoomGameModel *model = [MSRoomGameModel modelWithJSON:data.data]; + [[self getView]getRoomGameDetailsSuccessWithModel:model]; + }] roomType:roomType]; +} +- (void)enterNIMRoom:(NSString *)roomId user:(UserInfoModel *)userInfo { + NIMChatroomEnterRequest *request = [[NIMChatroomEnterRequest alloc] init]; + request.roomId = roomId; + //设置ext + XPMessageRemoteExtModel * extModel = [[XPMessageRemoteExtModel alloc] init]; + extModel.defUser = userInfo.defUser; + extModel.erbanNo = userInfo.erbanNo; + extModel.carName = userInfo.carName; + extModel.inRoomNameplatePic = userInfo.nameplatePic; + extModel.inRoomNameplateWord = userInfo.nameplateWord; + extModel.isCustomWord = userInfo.isCustomWord; + extModel.charmUrl = userInfo.userLevelVo.charmUrl; + extModel.experLevelSeq = userInfo.userLevelVo.experLevelSeq; + extModel.experUrl = userInfo.userLevelVo.experUrl; + extModel.newUser = userInfo.newUser; + extModel.vipIcon = userInfo.userVipInfoVO.vipIcon; + extModel.fromUid = userInfo.fromUid; + extModel.fromType = userInfo.fromType; + extModel.fromNick = userInfo.fromNick; + extModel.iosBubbleUrl = userInfo.iosBubbleUrl; + extModel.androidBubbleUrl = userInfo.androidBubbleUrl; + extModel.enterHide = userInfo.userVipInfoVO.enterHide; + extModel.preventKick = userInfo.userVipInfoVO.preventKick; + extModel.enterRoomEffects = userInfo.userVipInfoVO.enterRoomEffects; + extModel.gender = userInfo.gender; + extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel; + extModel.platformRole = userInfo.platformRole; + + NSMutableDictionary *ext = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]]; + request.roomExt = [ext toJSONString]; + [[NIMSDK sharedSDK].chatroomManager enterChatroom:request completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) { + if (error) { + + } else { + + } + }]; + +} + +- (void)exitNIMRoom:(NSString *)roomId { + [[NIMSDK sharedSDK].chatroomManager exitChatroom:roomId completion:nil]; + +} @end diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h b/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h index 04980e5b..a0dd6792 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h @@ -9,11 +9,13 @@ #import "UserInfoModel.h" #import "WalletInfoModel.h" #import "MSTabbarRoomGameModel.h" +#import "MSRoomGameModel.h" NS_ASSUME_NONNULL_BEGIN @protocol MSRoomGameProtocol -(void)getRoomGameConfigSuccessWithUser:(UserInfoModel *)user coinModel:(WalletInfoModel *)coinModel gameModel:(MSTabbarRoomGameModel *)gameModel; -(void)startMatchGameSuccess; +-(void)getRoomGameDetailsSuccessWithModel:(MSRoomGameModel *)model; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.h b/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.h index 188de001..192c964b 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.h @@ -6,11 +6,13 @@ // #import "MvpViewController.h" - +#import "MSTabbarRoomGameModel.h" +#import "UserInfoModel.h" NS_ASSUME_NONNULL_BEGIN @interface MSRoomGameVC : MvpViewController -- (instancetype)initWithRoomUid:(NSString *)roomUid; +@property(nonatomic,strong) MSTabbarRoomGameItemModel *chooseGameModel; +@property(nonatomic,strong) UserInfoModel *userinfo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m b/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m index cd52a47e..6b5a90b1 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m @@ -13,31 +13,42 @@ #import "XPRoomLittleGameContainerView.h" #import "MSRoomGameVictoryView.h" #import "MSRoomGameQuitGameView.h" -@interface MSRoomGameVC () +#import "MSRoomGamePresenter.h" +#import "MSRoomGameProtocol.h" +#import +#import "AttachmentModel.h" +@interface MSRoomGameVC () @property(nonatomic,strong) UIImageView *bgImageView; @property(nonatomic,strong) MSRoomGameHeadView *headView; @property(nonatomic,strong) MsRoomMessagChatHallView *chatView; @property(nonatomic,strong) MSRoomGameMsgView *msgView; -@property (nonatomic,copy)NSString *roomUid; +@property(nonatomic,copy) NSString *roomId; @property(nonatomic,strong) MSRoomGameSendMsgView *sendMsgView; ///小游戏的容器 @property (nonatomic,strong) XPRoomLittleGameContainerView *littleGameView; @end @implementation MSRoomGameVC -- (instancetype)initWithRoomUid:(NSString *)roomUid { - self = [super init]; - if (self) { - self.roomUid = roomUid; - } - return self; +- (MSRoomGamePresenter *)createPresenter { + return [[MSRoomGamePresenter alloc] init]; +} +-(void)dealloc{ + [[NIMSDK sharedSDK].chatroomManager removeDelegate:self]; + [[NIMSDK sharedSDK].chatManager removeDelegate:self]; + [[NIMSDK sharedSDK].loginManager removeDelegate:self]; + [[NIMSDK sharedSDK].conversationManager removeDelegate:self]; + } - (void)viewDidLoad { [super viewDidLoad]; [self installUI]; [self installConstraints]; + [self.presenter getRoomGameDetailWithRoomType:@"0"]; + [[NIMSDK sharedSDK].chatroomManager addDelegate:self]; + [[NIMSDK sharedSDK].chatManager addDelegate:self]; + [[NIMSDK sharedSDK].loginManager addDelegate:self]; + [[NIMSDK sharedSDK].conversationManager addDelegate:self]; - } -(void)installUI{ [self.view addSubview:self.bgImageView]; @@ -71,6 +82,13 @@ - (BOOL)isHiddenNavBar { return YES; } + +#pragma mark - MSRoomGameProtocol +-(void)getRoomGameDetailsSuccessWithModel:(MSRoomGameModel *)model{ + self.headView.roomGameModel = model; + self.roomId = model.roomId; + [self.presenter enterNIMRoom:model.roomId user:self.userinfo]; +} #pragma mark -MSRoomGameVictoryViewDelegate - (void)closeGameAction{ @@ -80,17 +98,85 @@ } #pragma mark - MSRoomGameQuitGameViewDelegate - (void)quitGameAction{ - + [self dismissViewControllerAnimated:YES completion:nil]; } #pragma mark -MSRoomGameHeadViewDelegate - (void)clickQuitGameAction{ -// MSRoomGameQuitGameView *quitGameView = [[MSRoomGameQuitGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; -// quitGameView.delegate = self; -// [TTPopup popupView:quitGameView style:TTPopupStyleAlert]; - MSRoomGameVictoryView *victoryView = [[MSRoomGameVictoryView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - victoryView.delegate = self; - [TTPopup popupView:victoryView style:TTPopupStyleAlert]; + MSRoomGameQuitGameView *quitGameView = [[MSRoomGameQuitGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + quitGameView.delegate = self; + [TTPopup popupView:quitGameView style:TTPopupStyleAlert]; +// MSRoomGameVictoryView *victoryView = [[MSRoomGameVictoryView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; +// victoryView.delegate = self; +// [TTPopup popupView:victoryView style:TTPopupStyleAlert]; + + } + +#pragma mark - NIMChatManagerDelegate +- (void)onRecvMessages:(NSArray *)messages { + for (NIMMessage * message in messages) { + + + // 非房间内消息不处理 + if (message.session.sessionType != NIMSessionTypeChatroom) { + continue; + } + + if(![message.session.sessionId isEqualToString:self.roomId]){ + + continue; + } + if (message.messageType == NIMMessageTypeNotification) { + NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; + NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; + switch (content.eventType) { + case NIMChatroomEventTypeEnter: + { + [self.msgView handleNIMNotificationMessage:message]; + break; + }; + + default: + break; + } + }else if (message.messageType == NIMMessageTypeText) { + [self.msgView handleNIMTextMessage:message]; + }else if (message.messageType == NIMMessageTypeCustom) { + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { + AttachmentModel * attachment = (AttachmentModel *)obj.attachment; + if(attachment.first == CustomMessageType_Chat_Room_Game && attachment.second == Custom_Message_Sub_Room_Game_Match_Success){ + [self.presenter exitNIMRoom:self.roomId]; + MSRoomGameModel *model = [MSRoomGameModel modelWithJSON:attachment.data]; + self.roomId = model.roomId; + self.headView.roomGameModel = model; + [self.presenter enterNIMRoom:model.roomId user:self.userinfo]; + + }if(attachment.first == CustomMessageType_Chat_Room_Game && attachment.second == Custom_Message_Sub_Room_Game_Match_Fail){ + [self.presenter exitNIMRoom:self.roomId]; + [self showErrorToast:YMLocalizedString(@"MSRoomGameVC0")]; + [self dismissViewControllerAnimated:YES completion:nil]; + + } + } + + } + } +} +#pragma mark - NIMBroadcastDelegate + +//发送消息成功回调 +- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { + // 非本房间不处理 + if([message.session.sessionId isEqualToString:self.roomId]){ + return;; + } + if (message.messageType == NIMMessageTypeText) { + [self.msgView handleNIMTextMessage:message]; + } + +} + #pragma mark - 懒加载 - (UIImageView *)bgImageView{ if(!_bgImageView){ @@ -104,12 +190,13 @@ if(!_headView){ _headView = [[MSRoomGameHeadView alloc]initWithFrame:CGRectZero]; _headView.delegate = self; + _headView.chooseGameModel = self.chooseGameModel; } return _headView; } - (MSRoomGameMsgView *)msgView{ if(!_msgView){ - _msgView = [[MSRoomGameMsgView alloc]initWithRoomUid:self.roomUid]; + _msgView = [[MSRoomGameMsgView alloc]initWithFrame:CGRectZero]; } return _msgView; } diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m index 238f0e5c..766cbaa3 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m @@ -20,6 +20,8 @@ @property(nonatomic,strong) MSTabbarRoomGameHeadView *headView; @property(nonatomic,strong) MSTabbarRoomGameView *gameView; @property(nonatomic,strong) MSTabbarRoomGameModel *gameModel; +@property(nonatomic,strong) MSTabbarRoomGameItemModel *chooseGameModel; + @end @implementation MSTabbarRoomGameVC @@ -90,15 +92,21 @@ } #pragma mark -MSTabbarRoomGameViewDelegate -(void)chooseGameType:(MSTabbarRoomGameItemModel *)model{ -// MSTabbarBeginGameView *beginGameView = [[MSTabbarBeginGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; -// beginGameView.itemModel = model; -// beginGameView.delegate = self; -// [kWindow addSubview:beginGameView]; + MSTabbarBeginGameView *beginGameView = [[MSTabbarBeginGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + beginGameView.itemModel = model; + beginGameView.delegate = self; + self.chooseGameModel = model; + [kWindow addSubview:beginGameView]; + + +} +-(void)startMatchGameSuccess{ MSRoomGameVC *gameVC = [MSRoomGameVC new]; + gameVC.chooseGameModel = self.chooseGameModel; + gameVC.userinfo = self.headView.userModel; BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:gameVC]; nav.modalPresentationStyle = UIModalPresentationFullScreen; [self presentViewController:nav animated:YES completion:nil]; - } #pragma mark - XPIAPRechargeViewControllerDelegate - (void)paySuccess{ diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.h b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.h index 60d9b466..db1e8dd7 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MSRoomGameHeadAvatarView : UIView - +@property(nonatomic,copy) NSString *imageUrl; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.m b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.m index 1f494e82..ab2df97f 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadAvatarView.m @@ -35,6 +35,10 @@ }]; } +-(void)setImageUrl:(NSString *)imageUrl{ + _imageUrl = imageUrl; + _avatarView.imageUrl = imageUrl; +} #pragma mark - 懒加载 - (NetImageView *)avatarView{ if(!_avatarView){ diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.h b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.h index e82155db..d0054f3a 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.h @@ -6,7 +6,8 @@ // #import - +#import "MSRoomGameModel.h" +#import "MSTabbarRoomGameModel.h" NS_ASSUME_NONNULL_BEGIN @protocol MSRoomGameHeadViewDelegate @@ -15,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN @end @interface MSRoomGameHeadView : UIView @property(nonatomic,weak) iddelegate; +@property(nonatomic,strong) MSRoomGameModel *roomGameModel; +@property(nonatomic,strong) MSTabbarRoomGameItemModel *chooseGameModel; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.m b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.m index e05910e6..7a86feb0 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameHeadView.m @@ -7,9 +7,10 @@ #import "MSRoomGameHeadView.h" #import "MSRoomGameHeadAvatarView.h" +#import "HomePlayRoomModel.h" @interface MSRoomGameHeadView() -@property(nonatomic,strong) UIImageView *topImageView; +@property(nonatomic,strong) NetImageView *topImageView; @property(nonatomic,strong) UIButton *backBtn; @property(nonatomic,strong) UILabel *titleView; @property(nonatomic,strong) UIImageView *pkImageView; @@ -104,11 +105,38 @@ [self.delegate clickQuitGameAction]; } } +-(void)setChooseGameModel:(MSTabbarRoomGameItemModel *)chooseGameModel{ + _chooseGameModel = chooseGameModel; + id coin = _chooseGameModel.scores.firstObject; + if(coin != nil){ + self.coinNumView.text = [NSString stringWithFormat:@"%@",coin]; + } +} +- (void)setRoomGameModel:(MSRoomGameModel *)roomGameModel{ + _roomGameModel = roomGameModel; + NSString *uid = [[AccountInfoStorage instance]getUid]; + for (MSRoomGameMicModel *obj in _roomGameModel.roomMics) { + if([obj.micUser.uid isEqualToString:uid]){ + self.mineView.imageUrl = obj.micUser.avatar; + }else{ + self.rivalView.imageUrl = obj.micUser.avatar; + } + + } + MSRoomGameInfoModel *data = _roomGameModel.data; + if(data != nil){ + _topImageView.imageUrl = data.gameRoomIcon; + if (data.matchStatus == MSRoomGameInfoModelMatchmaking){ + _titleView.text = YMLocalizedString(@"MSRoomGameHeadView0"); + }else if(data.matchStatus == MSRoomGameInfoModelMatchSuccessfully){ + _titleView.text = YMLocalizedString(@"MSRoomGameHeadView1"); + } + } +} #pragma mark - 懒加载 -- (UIImageView *)topImageView{ +- (NetImageView *)topImageView{ if(!_topImageView){ - _topImageView = [UIImageView new]; - _topImageView.image = kImage(@"ms_room_game_underwa_top_icon"); + _topImageView = [NetImageView new]; } return _topImageView; } @@ -123,7 +151,7 @@ } - (UILabel *)titleView{ if(!_titleView){ - _titleView = [UILabel labelInitWithText:@"匹配中" font:kFontBold(18) textColor:[UIColor whiteColor]]; + _titleView = [UILabel labelInitWithText:YMLocalizedString(@"MSRoomGameHeadView0") font:kFontBold(18) textColor:[UIColor whiteColor]]; } return _titleView; } @@ -149,7 +177,7 @@ - (UILabel *)hintView{ if(!_hintView){ _hintView = [UILabel new]; - NSMutableAttributedString *attText = [[NSMutableAttributedString alloc]initWithString:@"获胜奖励18金币" attributes:@{NSFontAttributeName:kFontMedium(14),NSForegroundColorAttributeName:[UIColor whiteColor]}]; + NSMutableAttributedString *attText = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:YMLocalizedString(@"MSRoomGameHeadView0"),@"18"] attributes:@{NSFontAttributeName:kFontMedium(14),NSForegroundColorAttributeName:[UIColor whiteColor]}]; [attText addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xFF6629)} range:[attText.string rangeOfString:@"18金币"]]; _hintView.attributedText = attText; _hintView.numberOfLines = 0; diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.h b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.h index 8a8da464..2b164d8e 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.h @@ -6,13 +6,14 @@ // #import - +#import #import "UserInfoModel.h" NS_ASSUME_NONNULL_BEGIN @interface MSRoomGameMsgView : UIView @property(nonatomic,strong) UserInfoModel *userInfo; -- (instancetype)initWithRoomUid:(NSString *)roomUid; +- (void)handleNIMNotificationMessage:(NIMMessage *)message; +- (void)handleNIMTextMessage:(NIMMessage *)message; @end diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.m b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.m index 0049c393..e3939507 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameMsgView.m @@ -8,7 +8,7 @@ #import "MSRoomGameMsgView.h" ///Third #import -#import + ///Tool #import "DJDKMIMOMColor.h" @@ -68,17 +68,17 @@ - (void)dealloc { } - -- (instancetype)initWithRoomUid:(NSString *)roomUid { - self = [super init]; - if (self) { - self.isLoadHistoryMessage = YES; - self.roomUid = roomUid; +-(instancetype)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ [self initSubViews]; [self initSubViewConstraints]; } return self; } + +#pragma mark - 懒加载 + #pragma mark - JXCategoryListContentViewDelegate - (UIView *)listView { return self; @@ -190,7 +190,7 @@ option.limit = 100; option.startTime = 0; option.order = NIMMessageSearchOrderAsc; - option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeImage)]; + option.messageTypes = @[@(NIMMessageTypeText)]; [[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray * _Nullable messages) { if(error != nil){ self.isLoadHistoryMessage = NO; @@ -201,7 +201,7 @@ NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init]; option.limit = 100; option.order = NIMMessageSearchOrderDesc; - option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeImage)]; + option.messageTypes = @[@(NIMMessageTypeText)]; [[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray * _Nullable messages) { if(error != nil){ self.isLoadHistoryMessage = NO; @@ -253,36 +253,8 @@ BOOL isHaveSave = NO; if(item.messageType == NIMMessageTypeText){ isHaveSave = YES; - }else if(item.messageType == NIMMessageTypeImage){ - isHaveSave = YES; - }else if(item.messageType == NIMMessageTypeCustom){ - NIMCustomObject *obj = (NIMCustomObject *)item.messageObject; - if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { - AttachmentModel *attachment = (AttachmentModel *)obj.attachment; - if (attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn) { - isHaveSave = YES; - } - - } } if(isHaveSave == NO)return; - if (item.messageType == NIMMessageTypeImage){ - PIRoomPhotoAlbumItemModel*model = [PIRoomPhotoAlbumItemModel new]; - model.type = @"1"; - model.status = 1; - NIMImageObject * imageObject = (NIMImageObject*)item.messageObject; - model.photoUrl = imageObject.url; - XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init]; - messageInfo.albumModel = model; - messageInfo.first = CustomMessageType_Room_Album; - XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithJSON:item.remoteExt[item.from]]; - messageInfo.charmUrl = extModel.charmUrl; - messageInfo.experUrl = extModel.experUrl; - messageInfo.bubbleImageUrl = extModel.iosBubbleUrl; - messageInfo.nameText = extModel.nick; - [self.datasource addObject:messageInfo]; - return; - } [self.datasource addObject:[self.messageParser parseMessageAttributeForChatHall:item]]; } - (void)handleNIMTextMessage:(NIMMessage *)message { @@ -315,17 +287,7 @@ return self.datasource.count; } -//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { -// XPMessageInfoModel* messageInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; -// -// if(messageInfo.first == CustomMessageType_Room_Album){ -// return 186; -// }else if(messageInfo.first == CustomMessageType_Chat_Hall_Headlinesn){ -// return 40; -// } -// -// return messageInfo.rowHeight; -//} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { XPMessageInfoModel* attr = [self.datasource safeObjectAtIndex1:indexPath.row]; diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameView.m b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameView.m index 4638a31d..1d9e01e3 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameView.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSRoomGameView.m @@ -37,7 +37,7 @@ ///小游戏code @property (nonatomic, copy) NSString *code; /// -@property (nonatomic,weak) id hostDelegate; +@property(nonatomic,copy) NSString *mgId; @property (nonatomic, strong) id fsmAPP2MG; /// 你画我猜专用,游戏中选中的关键词,会回调出来,通过 DrawSomethingKeyWord 进行保存。 @property (nonatomic, copy) NSString * DrawSomethingKeyWord; @@ -48,821 +48,821 @@ @end @implementation MSRoomGameView -- (instancetype)initWithDelegate:(id)delegate -{ - self = [super init]; - if (self) { - self.hostDelegate = delegate; - } - return self; -} - -#pragma mark - Private Method -- (void)updateSudGame { - RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; - if (roomInfo.type == RoomType_MiniGame) { - if (self.currentmgId == 0) {//第一次加载游戏 - self.currentmgId = roomInfo.mgId; - if (self.currentmgId != 0) {//房间信息已加载 - NSLog(@"initLittleGame---%lld", self.currentmgId); - [self initLittleGame]; - } - } else { - if (self.currentmgId != roomInfo.mgId) { - //切换游戏玩法 - self.currentmgId = roomInfo.mgId; - NSLog(@"updateLittleGame---%lld", self.currentmgId); - if (self.currentmgId != 0) { - [self.fsmAPP2MG destroyMG]; - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; - [self gameSetUp]; - } - } - } - } -} - -- (void)initLittleGame { - [Api getSudGameCode:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - NSString * gameCode = data.data[@"code"]; - self.code = gameCode; - [self gameSetUp]; - } else { - [XNDJTDDLoadingTool showErrorWithMessage:msg]; - } - } uid:[AccountInfoStorage instance].getUid]; -} - -- (void)gameSetUp { - NSLog(@"小游戏的版本号是:%@", [SudMGP getVersion]); - BOOL isTestEnv = NO; -#ifdef DEBUG - isTestEnv = YES; -#else - isTestEnv = NO; -#endif - if(isEnterprise == NO){ - [[SudMGP getCfg]setBackgroundMode:NO]; - } - [SudMGP initSDK:KeyWithType(KeyType_SudGameAppID) appKey:KeyWithType(KeyType_SudGameAppKey) isTestEnv:isTestEnv listener:^(int retCode, const NSString *retMsg) { - if (retCode == 0) { - if (!self.currentmgId) { - return; - } - NSString * userId = [AccountInfoStorage instance].getUid; - NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; - NSLog(@"用户ID:%@,房间ID:%@, 游戏ID:%lld, code:%@", userId, roomId, self.currentmgId, self.code); +//- (instancetype)initWithmgId:(NSString *)mgId +//{ +// self = [super init]; +// if (self) { +// self.mgId = mgId; +// } +// return self; +//} // - - NSString *language = [NSBundle getLanguageText]; - if ([language hasPrefix:@"zh"]) { - if ([language rangeOfString:@"Hans"].location != NSNotFound) { - language = @"zh-CN"; // 简体中文 - } else { - language = @"zh-TW"; // 繁體中文 - } - }else{ - language = @"en-US"; // 英文 - } - self.fsmAPP2MG = [SudMGP loadMG:userId roomId:roomId code:self.code mgId:self.currentmgId language:language fsmMG:self rootView:self]; - } else { - /// 初始化失败, 可根据业务重试 - NSLog(@"ISudFSMMG:initGameSDKWithAppID:初始化sdk失败 :%@",retMsg); - } - }]; -} - -//判断是否在麦上 -- (BOOL)isOnMicro:(NSInteger)uid{ - NSArray *chatRoomMicSequences = [self.hostDelegate.getMicroQueue allValues] ; - if (chatRoomMicSequences != nil && chatRoomMicSequences.count > 0) { - for (int i = 0; i < chatRoomMicSequences.count; i ++) { - MicroQueueModel *chatRoomMicSequence = chatRoomMicSequences[i]; - if (chatRoomMicSequence.userInfo.uid == uid) { - return YES; - } - } - } - return NO; -} - -- (NSString *)findFreePosition{ - NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; - if (micQueue != nil && micQueue.allKeys.count > 0) { - NSArray *keys = [micQueue allKeys]; - if (keys.count > 0) { - ///重新排序,按照升序 - NSArray *resultArr = [keys sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { - return [obj1 compare:obj2]; - }]; - for (NSString *key in resultArr) { - UserInfoModel *userInfo = [[micQueue objectForKey:key] userInfo]; - if ( !userInfo) { - return key; - } - } - } - } - return nil; -} - -//通过uid判断麦位 -- (NSString *)findThePositionByUid:(NSInteger)uid{ - if (uid > 0) { - NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; - NSArray *keys = [micQueue allKeys]; - if (keys.count > 0) { - for (NSString *key in keys) { - UserInfoModel *userInfo = [[micQueue objectForKey:key] userInfo]; - if (userInfo.uid == uid) { - return key; - } - } - } - } - return nil; -} - -//上麦以加入游戏 -- (void)upMicToJoinGame { - NSString *position = [self findFreePosition]; - if (position.length > 0) { - NSString * userId = [AccountInfoStorage instance].getUid; - UserInfoModel * userInfo = self.hostDelegate.getUserInfo; - //清空该uid之前在队列中的信息 - if ([self isOnMicro:userId.integerValue]) { - if (position) { - NSString *findOldPosition = [self findThePositionByUid:userInfo.uid]; - NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc]init]; - request.key = findOldPosition; - request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - if (findOldPosition) { - [[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary * _Nullable element) { - if (error == nil) { - NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; - request.key = position; - request.value = [[self userInfoToQueueExt:userInfo] toJSONString]; - request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - request.transient = YES; - [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { - [self notifySelfInState:YES seatIndex:-1]; - }]; - } - }]; - } - } - }else{ - NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; - request.key = position; - request.value = [[self userInfoToQueueExt:userInfo] toJSONString]; - request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - request.transient = YES; - [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { - [self notifySelfInState:YES seatIndex:-1]; - }]; - } - } -} - -- (void)updateMicInfoWithGameStatus:(LittleGamePlayStatus)status { - NSString * position = [self findThePositionByUid:[AccountInfoStorage instance].getUid.integerValue]; - if (position != nil) { - UserInfoModel * userInfo = self.hostDelegate.getUserInfo; - userInfo.gameStatus = status; - NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; - request.key = position; - request.value = [[self userInfoToQueueExt:userInfo] toJSONString]; - request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - request.transient = YES; - [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { - - }]; - } -} - -/** - * 麦位更新扩展字段。 - */ -- (NSDictionary *)userInfoToQueueExt:(UserInfoModel *)userInfo { - MicroExtModel * extModel = [[MicroExtModel alloc] init]; - extModel.gender = userInfo.gender; - extModel.avatar = userInfo.avatar; - extModel.uid = userInfo.uid; - extModel.nick = userInfo.nick; - extModel.gameStatus = userInfo.gameStatus; - extModel.headWearUrl = userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic; - extModel.preventKick = userInfo.userVipInfoVO.preventKick; - extModel.enterHide = userInfo.userVipInfoVO.enterHide; - return [extModel model2dictionary]; -} - -//自己是否在游戏中 -- (BOOL)isInSudGame { - BOOL isGamePlaying = NO; - if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { - for (int i = -1; i<5; i++) { - NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; - MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; - if (micSequence == nil || micSequence.userInfo == nil) { - continue; - } - if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { - isGamePlaying = YES; - break; - } - } - } - return isGamePlaying; -} - -//游戏状态 -- (LittleGamePlayStatus)getCurrentUserSudGameStatus { - LittleGamePlayStatus gameStatus = LittleGamePlayStatus_NoIn; - for (int i = -1; i<5; i++) { - NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; - MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; - if (micSequence == nil || micSequence.userInfo == nil) { - continue; - } - if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { - gameStatus = micSequence.userInfo.gameStatus; - break; - } - } - return gameStatus; -} - -///下麦 -- (void)onDownMic:(NSInteger)uid { - if (uid == [AccountInfoStorage instance].getUid.integerValue) {//自己下麦 - [self notifyIsPlayingState:false]; - [self nofityPlayerPlaying:NO]; - [self notifySetReady:false]; - /// 下游戏麦 - [self notifySelfInState:false seatIndex:-1]; - } -} - -#pragma mark =======ISudFSMMG Delegate======= -/** -* 游戏日志 -*/ --(void)onGameLog:(NSString*)dataJson { - NSLog(@"ISudFSMMG:onGameLog:%@", dataJson); - NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; - NSString * msg_string = [dic objectForKey:@"msg"]; - if (!msg_string) { - return; - } -} - -/** -* 游戏开始 -*/ --(void)onGameStarted { - NSLog(@"ISudFSMMG:onGameStarted:游戏开始"); -} - -/** - * 游戏销毁 - */ --(void)onGameDestroyed { - NSLog(@"ISudFSMMG:onGameDestroyed:游戏开始"); -} - -/** - * Code过期 - * @param dataJson {"code":"value"} - */ --(void)onExpireCode:(id)handle dataJson:(NSString*)dataJson { - NSLog(@"ISudFSMMG:onExpireCode:Code过期"); - // 请求业务服务器刷新令牌 - [Api getSudGameCode:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - NSString * gameCode = data.data[@"code"]; - self.code = gameCode; - [self.fsmAPP2MG updateCode:gameCode listener:^(int retCode, const NSString *retMsg, const NSString *dataJson) { - NSLog(@"ISudFSMMG:updateGameCode retCode=%@ retMsg=%@ dataJson=%@", @(retCode), retMsg, dataJson); - }]; - // 回调结果 - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@(0), @"ret_code", @"return form APP onExpireCode", @"ret_msg", nil]; - [handle success:[SudCommon dictionaryToJson:dict]]; - } else { - [XNDJTDDLoadingTool showErrorWithMessage:msg]; - } - } uid:[AccountInfoStorage instance].getUid]; -} - -/** - * 获取游戏View信息 - * @param handle 回调句柄 - * @param dataJson {} - */ --(void)onGetGameViewInfo:(id)handle dataJson:(NSString*)dataJson { - CGRect rect = [[UIScreen mainScreen] bounds]; - CGFloat scale = [[UIScreen mainScreen] nativeScale]; - - CGFloat top = (kNavigationHeight+105) * scale; - CGFloat bottom; - if (iPhoneXSeries) { - bottom = (47+kSafeAreaBottomHeight+30 + 70) * scale; - } else { - bottom = (47+10+70 ) * scale; - } - CGFloat width = rect.size.width * scale; - CGFloat height = rect.size.height * scale; - NSDictionary *rectDict = [NSDictionary dictionaryWithObjectsAndKeys:@(top), @"top", @(0), @"left", @(bottom), @"bottom", @(0), @"right", nil]; - NSDictionary *viewDict = [NSDictionary dictionaryWithObjectsAndKeys:@(width), @"width", @(height), @"height", nil]; - NSDictionary *dataDict = [NSDictionary dictionaryWithObjectsAndKeys:@(0), @"ret_code", @"return form APP onGetGameViewInfo", @"ret_msg", viewDict, @"view_size", rectDict, @"view_game_rect", nil]; - /// 回调 - [handle success:[SudCommon dictionaryToJson:dataDict]]; -} - -/** - * 获取游戏配置 - * @param handle 回调句柄 - * @param dataJson {} - */ --(void)onGetGameCfg:(id)handle dataJson:(NSString*)dataJson { - NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; - dict[@"ret_code"] = @(0); - dict[@"ret_msg"] = @"return form APP onGetGameCfg"; - - dict[@"ui"] = @{ - @"join_btn" : @{@"custom": @(YES), @"hide": @(NO)},//加入游戏 - @"start_btn" : @{@"custom": @(YES), @"hide": @(NO)},//开始游戏 - @"lobby_players" : @{@"custom": @(YES), @"hide": @(NO)},//游戏中坑位点击 - @"level" : @{@"custom": @(YES), @"hide" : @(YES)},//段位信息 - }; - NSString *dataJsonRet = @""; - NSData *dataJsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil]; - if (dataJsonData != nil) { - dataJsonRet = [[NSString alloc]initWithData:dataJsonData encoding:NSUTF8StringEncoding]; - } - [handle success:dataJsonRet]; -} - -/** - * 游戏状态变化 - * @param handle 回调句柄 - * @param state 游戏状态 - * @param dataJson 回调json - */ --(void)onGameStateChange:(id) handle state:(NSString*) state dataJson:(NSString*) dataJson { - if ([state isEqualToString:MG_COMMON_PUBLIC_MESSAGE]) { - NSLog(@"ISudFSMMG:onGameStateChange:游戏->APP:公屏消息"); - } else if ([state isEqualToString:MG_COMMON_KEY_WORD_TO_HIT]) { - NSDictionary *dic = [SudCommon turnStringToDictionary:dataJson]; - NSString *word = [dic objectForKey:@"word"]; - NSLog(@"ISudFSMMG:onGameStateChange:游戏->APP:你画我猜关键词获取:%@",word); - /// 记录你画我猜关键字 - self.DrawSomethingKeyWord = word; - if (word == (id) [NSNull null] || [word isEqualToString:@""]) { - /// 关闭公屏关键词hit状态 - self.keyWordHiting = NO; - } else { - /// 开启公屏关键词hit状态 - self.keyWordHiting = YES; - } - }else if ([state isEqualToString:MG_COMMON_SELF_CLICK_JOIN_BTN]) {//加入游戏按钮点击 - NSDictionary *dic = [SudCommon turnStringToDictionary:dataJson]; - int seatIndex = -1; - if ([dic objectForKey:@"seatIndex"]) { - seatIndex = [[dic objectForKey:@"seatIndex"] intValue]; - } - if (seatIndex == -1) { - NSLog(@"来自加入按钮%d",seatIndex); - }else { - NSLog(@"来自麦位+入%d",seatIndex); - } - if ([self isOnMicro:[AccountInfoStorage instance].getUid.integerValue]) {//判断是否在麦上 - [self notifySelfInState:YES seatIndex:seatIndex]; - } else { - //不在麦上 - [self upMicToJoinGame]; - } - } else if([state isEqualToString:MG_COMMON_SELF_CLICK_START_BTN]) {//开始游戏按钮点击 - [self notifyIsPlayingState:YES]; - } else if ([state isEqualToString:MG_COMMON_SELF_CLICK_CANCEL_JOIN_BTN]) { - /// 取消加入游戏(退出游戏按钮点击) - [self handleSelfInExitEvent]; - } else { - /// 其他状态 - NSLog(@"ISudFSMMG:onGameStateChange:游戏->APP:state:%@",MG_COMMON_PUBLIC_MESSAGE); - } -} - -/** - * 游戏玩家状态变化 - * @param handle 回调句柄 - * @param userId 用户id - * @param state 玩家状态 - * @param dataJson 回调JSON - */ --(void)onPlayerStateChange:(nullable id) handle userId:(NSString*) userId state:(NSString*) state dataJson:(NSString*) dataJson { - NSLog(@"ISudFSMMG:onPlayerStateChange:游戏->APP:游戏玩家状态变化:userId: %@ --state: %@ --dataJson: %@", userId, state, dataJson); - /// 状态解析 - NSString *dataStr = @""; - if ([state isEqualToString:MG_COMMON_PLAYER_IN]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView0"); - [self handleState_MG_COMMON_PLAYER_IN_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_COMMON_PLAYER_READY]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView1"); - [self handleState_MG_COMMON_PLAYER_READY_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_COMMON_PLAYER_CAPTAIN]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView2"); - [self handleState_MG_COMMON_PLAYER_CAPTAIN_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_COMMON_PLAYER_PLAYING]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView3"); - [self handleState_MG_COMMON_PLAYER_PLAYING_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_DG_SELECTING]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView4"); - [self handleState_MG_DG_SELECTING_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_DG_PAINTING]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView5"); - [self handleState_MG_DG_PAINTING_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_DG_ERRORANSWER]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView6"); - [self handleState_MG_DG_ERRORANSWER_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_DG_TOTALSCORE]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView7"); - [self handleState_MG_DG_TOTALSCORE_WithUserId:userId dataJson:dataJson]; - } else if ([state isEqualToString:MG_DG_SCORE]) { - dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView8"); - [self handleState_MG_DG_SCORE_WithUserId:userId dataJson:dataJson]; - }else { - NSLog(@"ISudFSMMG:onPlayerStateChange:未做解析状态:%@", MG_DG_SCORE); - } - NSLog(@"ISudFSMMG:onPlayerStateChange:dataStr:%@", dataStr); - /// 回调 - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@(0), @"ret_code", @"return form APP onPlayerStateChange", @"ret_msg", nil]; - [handle success:[SudCommon dictionaryToJson:dict]]; -} - -/// 退出游戏 -- (void)handleSelfInExitEvent { - if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { - return; - } - /// 正在游戏中,只退出游戏 - if ([self getCurrentUserSudGameStatus] == LittleGamePlayStatus_Plying) { - [self notifyIsPlayingState:false]; - [self nofityPlayerPlaying:NO]; - [self notifySetReady:false]; - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; - } else if ([self getCurrentUserSudGameStatus] == LittleGamePlayStatus_Ready) { /// 非游戏状态下 - /// 如果已经准备先退出准备状态 - [self notifySetReady:false]; - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; - } else { - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; - } - /// 下游戏麦 - [self notifySelfInState:false seatIndex:-1]; -} - -/// 准备游戏 -- (void)handleSelfReadyEvent { - [self notifySetReady:true]; -} - -/// 取消准备 -- (void)handleSelfCancelReadyEvent { - [self notifySetReady:false]; -} - -/// 开始游戏 -- (void)handleGameStartEvent { - [self notifyIsPlayingState:YES]; -} - -#pragma mark =======APP->游戏状态处理======= -/// 状态通知(app to mg) -/// @param state 状态名称 -/// @param dataJson 需传递的json -- (void)notifyStateChange:(NSString *) state dataJson:(NSString*) dataJson { - [self.fsmAPP2MG notifyStateChange:state dataJson:dataJson listener:^(int retCode, const NSString *retMsg, const NSString *dataJson) { - NSLog(@"ISudFSMMG:notifyStateChange:retCode=%@ retMsg=%@ dataJson=%@", @(retCode), retMsg, dataJson); - RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; - if (retCode == 0 && [state isEqualToString:APP_COMMON_SELF_PLAYING]) {//开始游戏 - //上报游戏开始 - NSString *mgid = [NSString stringWithFormat:@"%lld", self.currentmgId]; - if (mgid.length <= 0) { - return; - } - [Api startGameCheck:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code != 200) { - [XNDJTDDLoadingTool showErrorWithMessage:msg]; - } - } roomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid] mgId:mgid]; - } else if (retCode == 0 && [state isEqualToString:APP_COMMON_SELF_END]) {//结束游戏 - - } - }]; -} - -/// 加入,退出游戏 -/// @param isIn YES:加入 NO:退出 -- (void)notifySelfInState:(BOOL)isIn uid:(NSInteger)uid { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isIn), @"isIn", @(1), @"teamId", nil]; - [self notifyStateChange:APP_COMMON_SELF_IN dataJson:[SudCommon dictionaryToJson:dic]]; -} - -/// 加入,退出游戏 -/// @param isIn YES:加入 NO:退出 -- (void)notifySelfInState:(BOOL)isIn seatIndex:(int)seatIndex { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(seatIndex), @"seatIndex", @(isIn), @"isIn", @(1), @"teamId", nil]; - [self notifyStateChange:APP_COMMON_SELF_IN dataJson:[SudCommon dictionaryToJson:dic]]; -} - -/// 踢出用户 -/// @param userId 踢出用户id -- (void)notifyKickStateWithUserId:(NSString *)userId { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:userId, @"kickedUID", nil]; - [self notifyStateChange:APP_COMMON_SELF_KICK dataJson:[SudCommon dictionaryToJson:dic]]; -} - -/// 设置用户为队长 -/// @param userId 被设置用户id -- (void)notifySetCaptainStateWithUserId:(NSString *)userId { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:userId, @"curCaptainUID", nil]; - [self notifyStateChange:APP_COMMON_SELF_CAPTAIN dataJson:[SudCommon dictionaryToJson:dic]]; -} - -/// 命中 关键词状态 (你画我猜) -- (void)notifyChangeTextHitState:(NSString *)keyWord { - if([keyWord isKindOfClass:[NSNull class]])return; - if (keyWord.length && [keyWord containsString:self.DrawSomethingKeyWord]) { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(true), @"isHit", self.DrawSomethingKeyWord, @"keyWord", self.DrawSomethingKeyWord, @"text", nil]; - [self notifyStateChange:APP_COMMON_SELF_TEXT_HIT dataJson:[SudCommon dictionaryToJson:dic]]; - } -} - -/// 是否设置为准备状态 -- (void)notifySetReady:(BOOL)isReady { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isReady), @"isReady", nil]; - [self notifyStateChange:APP_COMMON_SELF_READY dataJson:[SudCommon dictionaryToJson:dic]]; -} - -/// 停止游戏状态设置 -- (void)notifySetEnd { - [self notifyStateChange:APP_COMMON_SELF_END dataJson:[SudCommon dictionaryToJson:@{}]]; -} - -/// 游戏中状态设置 -- (void)notifyIsPlayingState:(BOOL)isPlaying { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isPlaying), @"isPlaying", nil]; - [self notifyStateChange:APP_COMMON_SELF_PLAYING dataJson:[SudCommon dictionaryToJson:dic]]; -} - -///游戏中退出游戏 -- (void)nofityPlayerPlaying:(BOOL)isPlaying { - NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isPlaying), @"isPlaying", nil]; - [self notifyStateChange:MG_COMMON_PLAYER_PLAYING dataJson:[SudCommon dictionaryToJson:dic]]; -} - -#pragma mark =======游戏->APP状态处理======= -- (void)handleState_MG_COMMON_PLAYER_IN_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; - /// 加入状态:YES加入,NO退出 - BOOL isIn = NO; - if (dic) { - NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; - if (retCode != 0) { - return; - } - isIn = [[dic objectForKey:@"isIn"] boolValue]; - } - if ([userId isEqualToString:[AccountInfoStorage instance].getUid]) {//是当前用户 - if (isIn) {//加入了游戏 - //判断是否在麦上 - if ([self isOnMicro:[userId longLongValue]]) { - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_IsIn]; - } else {//不在麦上 - [self upMicToJoinGame]; - } - //判断是否为房主,房主需要设为队长 - if (self.hostDelegate.getRoomInfo.uid == userId.integerValue) { - [self notifySetCaptainStateWithUserId:userId]; - } - self.sudGameStatus = LittleGamePlayStatus_IsIn; - }else {//退出了游戏 - //判断是否在麦上 - if ([self isOnMicro:[userId longLongValue]]) { - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; - } - self.sudGameStatus = LittleGamePlayStatus_NoIn; - } - } else {//退出游戏 - if (self.sudGameStatus == LittleGamePlayStatus_Plying) {//游戏进行中,用户退出 - ///自己是公会超管 - BOOL meIsSuperAdmin = NO; - for (GuildSuperAdminInfoModel *managerInfo in self.hostDelegate.getRoomSuperAdminList) { - if ([managerInfo.uid isEqualToString:[AccountInfoStorage instance].getUid]) { - meIsSuperAdmin = YES; - break; - } - } - NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; - request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - request.userIds = @[[AccountInfoStorage instance].getUid]; - [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { - if (error == nil) { - NIMChatroomMember *member = members.firstObject; - if (member.type == NIMChatroomMemberTypeManager || member.type == NIMChatroomMemberTypeCreator || meIsSuperAdmin) { - NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; - request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - request.userIds = @[userId]; - [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { - if (error == nil) { - NIMChatroomMember *member = members.firstObject; - [XNDJTDDLoadingTool showErrorWithMessage:[NSString stringWithFormat:YMLocalizedString(@"XPRoomLittleGameContainerView9"), member.roomNickname]]; - } - }]; - } - } - }]; - - } - } -} - -- (void)handleState_MG_COMMON_PLAYER_READY_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - /// 玩家是否准备,YES:已准备,NO:未准备 - BOOL isReady = NO; - NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; - if (dic) { - NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; - if (retCode != 0) { - return; - } - isReady = [[dic objectForKey:@"isReady"] boolValue]; - } - if ([userId isEqualToString:[AccountInfoStorage instance].getUid]) { - if (isReady) { - //判断是否在麦上 - if ([self isOnMicro:[userId longLongValue]]) { - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_Ready]; - } - self.sudGameStatus = LittleGamePlayStatus_Ready; - }else { - if ([self isOnMicro:[userId longLongValue]]) { - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_IsIn]; - } - self.sudGameStatus = LittleGamePlayStatus_IsIn; - } - } -} - -- (void)handleState_MG_COMMON_PLAYER_CAPTAIN_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - /// 是否是队长:YES:是队长 NO:不是队长 - BOOL isCaptain = NO; - NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; - if (dic) { - /// 错误处理 - NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; - if (retCode != 0) { - return; - } - isCaptain = [[dic objectForKey:@"isCaptain"] boolValue]; - } -} - -- (void)handleState_MG_COMMON_PLAYER_PLAYING_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - /// 是否正在游戏中 - BOOL isPlaying = NO; - NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; - if (dic) { - /// 错误处理 - NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; - if (retCode != 0) { - return; - } - isPlaying = [[dic objectForKey:@"isPlaying"] boolValue]; - } - if ([userId isEqualToString:[AccountInfoStorage instance].getUid]) { - if (isPlaying) { - //判断是否在麦上 - if ([self isOnMicro:[userId longLongValue]]) { - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_Plying]; - } - if (self.delegate && [self.delegate respondsToSelector:@selector(hiddenSudGamePostionView)]) { - [self.delegate hiddenSudGamePostionView]; - } - self.sudGameStatus = LittleGamePlayStatus_Plying; - }else { - if ([self isOnMicro:[userId longLongValue]]) { - [self updateMicInfoWithGameStatus:LittleGamePlayStatus_IsIn]; - } - self.sudGameStatus = LittleGamePlayStatus_IsIn; - } - } -} - -- (void)handleState_MG_DG_SELECTING_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - NSLog(@"handleState_MG_DG_SELECTING_WithUserId%@",dataJson); -} - -- (void)handleState_MG_DG_PAINTING_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - NSLog(@"handleState_MG_DG_PAINTING_WithUserId%@",dataJson); - /// 设置麦位状态为作画中 - NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; - bool isPainting = NO; - if (dic) { - isPainting = [dic[@"isPainting"] boolValue]; - } -} - -- (void)handleState_MG_DG_ERRORANSWER_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - /// 错误答案 - NSLog(@"handleState_MG_DG_ERRORANSWER_WithUserId%@",dataJson); - -} - -- (void)handleState_MG_DG_TOTALSCORE_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - /// 总积分 - NSLog(@"handleState_MG_DG_TOTALSCORE_WithUserId%@",dataJson); -} - -- (void)handleState_MG_DG_SCORE_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { - /// 本次积分 - NSLog(@"handleState_MG_DG_SCORE_WithUserId%@",dataJson); -} - -/// 销毁MG -- (void)destroyMG { - if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self.fsmAPP2MG destroyMG]; - }); - } -} - -#pragma mark - RoomGuestDelegate -- (void)onRoomEntered { - if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { - self.hidden = YES; - return; - } else { - self.hidden = NO; - } - [self updateSudGame]; -} - -- (void)onRoomUpdate { - if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { - self.hidden = YES; - [self.fsmAPP2MG destroyMG]; - } else { - self.hidden = NO; - } - [self updateSudGame]; -} -#pragma mark - RoomGuestDelegate -- (void)handleNIMCustomMessage:(NIMMessage *)message { - if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { - return; - } - NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { - AttachmentModel *attachment = (AttachmentModel *)obj.attachment; - if (attachment.first == CustomMessageType_Kick_User) { - XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; - [self onDownMic:kickModel.uid]; - } else if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Kick) { - XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; - [self onDownMic:kickModel.uid]; - } - } -} - -- (void)handleNIMNotificationMessage:(NIMMessage *)message { - if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) {return;} - NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; - NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; - switch (content.eventType) { - case NIMChatroomEventTypeQueueChange: // 麦序上下麦 - { - NSDictionary* data = (NSDictionary *)content.ext; - UserInfoModel* userInfo = [UserInfoModel modelWithJSON:[data objectForKey:NIMChatroomEventInfoQueueChangeItemValueKey]]; - NSInteger changeType = [data[NIMChatroomEventInfoQueueChangeTypeKey] integerValue]; - if (changeType != 1) { - [self onDownMic:userInfo.uid]; - } - } - break; - default: - break; - } -} - -- (void)handleNIMTextMessage:(NIMMessage *)message { - if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) {return;} - if (message.from.integerValue == [AccountInfoStorage instance].getUid.integerValue && [self isInSudGame]) { - [self notifyChangeTextHitState:message.text]; - } -} +//#pragma mark - Private Method +//- (void)updateSudGame { +// +// +// if (self.currentmgId == 0) {//第一次加载游戏 +// self.currentmgId = roomInfo.mgId; +// if (self.currentmgId != 0) {//房间信息已加载 +// NSLog(@"initLittleGame---%lld", self.currentmgId); +// [self initLittleGame]; +// } +// } else { +// if (self.currentmgId != roomInfo.mgId) { +// //切换游戏玩法 +// self.currentmgId = roomInfo.mgId; +// NSLog(@"updateLittleGame---%lld", self.currentmgId); +// if (self.currentmgId != 0) { +// [self.fsmAPP2MG destroyMG]; +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; +// [self gameSetUp]; +// } +// } +// } +// +//} +// +//- (void)initLittleGame { +// [Api getSudGameCode:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { +// if (code == 200) { +// NSString * gameCode = data.data[@"code"]; +// self.code = gameCode; +// [self gameSetUp]; +// } else { +// [XNDJTDDLoadingTool showErrorWithMessage:msg]; +// } +// } uid:[AccountInfoStorage instance].getUid]; +//} +// +//- (void)gameSetUp { +// NSLog(@"小游戏的版本号是:%@", [SudMGP getVersion]); +// BOOL isTestEnv = NO; +//#ifdef DEBUG +// isTestEnv = YES; +//#else +// isTestEnv = NO; +//#endif +// if(isEnterprise == NO){ +// [[SudMGP getCfg]setBackgroundMode:NO]; +// } +// [SudMGP initSDK:KeyWithType(KeyType_SudGameAppID) appKey:KeyWithType(KeyType_SudGameAppKey) isTestEnv:isTestEnv listener:^(int retCode, const NSString *retMsg) { +// if (retCode == 0) { +// if (!self.currentmgId) { +// return; +// } +// NSString * userId = [AccountInfoStorage instance].getUid; +// NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; +// NSLog(@"用户ID:%@,房间ID:%@, 游戏ID:%lld, code:%@", userId, roomId, self.currentmgId, self.code); +//// +// +// NSString *language = [NSBundle getLanguageText]; +// if ([language hasPrefix:@"zh"]) { +// if ([language rangeOfString:@"Hans"].location != NSNotFound) { +// language = @"zh-CN"; // 简体中文 +// } else { +// language = @"zh-TW"; // 繁體中文 +// } +// }else{ +// language = @"en-US"; // 英文 +// } +// self.fsmAPP2MG = [SudMGP loadMG:userId roomId:roomId code:self.code mgId:self.currentmgId language:language fsmMG:self rootView:self]; +// } else { +// /// 初始化失败, 可根据业务重试 +// NSLog(@"ISudFSMMG:initGameSDKWithAppID:初始化sdk失败 :%@",retMsg); +// } +// }]; +//} +// +////判断是否在麦上 +//- (BOOL)isOnMicro:(NSInteger)uid{ +// NSArray *chatRoomMicSequences = [self.hostDelegate.getMicroQueue allValues] ; +// if (chatRoomMicSequences != nil && chatRoomMicSequences.count > 0) { +// for (int i = 0; i < chatRoomMicSequences.count; i ++) { +// MicroQueueModel *chatRoomMicSequence = chatRoomMicSequences[i]; +// if (chatRoomMicSequence.userInfo.uid == uid) { +// return YES; +// } +// } +// } +// return NO; +//} +// +//- (NSString *)findFreePosition{ +// NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; +// if (micQueue != nil && micQueue.allKeys.count > 0) { +// NSArray *keys = [micQueue allKeys]; +// if (keys.count > 0) { +// ///重新排序,按照升序 +// NSArray *resultArr = [keys sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { +// return [obj1 compare:obj2]; +// }]; +// for (NSString *key in resultArr) { +// UserInfoModel *userInfo = [[micQueue objectForKey:key] userInfo]; +// if ( !userInfo) { +// return key; +// } +// } +// } +// } +// return nil; +//} +// +////通过uid判断麦位 +//- (NSString *)findThePositionByUid:(NSInteger)uid{ +// if (uid > 0) { +// NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; +// NSArray *keys = [micQueue allKeys]; +// if (keys.count > 0) { +// for (NSString *key in keys) { +// UserInfoModel *userInfo = [[micQueue objectForKey:key] userInfo]; +// if (userInfo.uid == uid) { +// return key; +// } +// } +// } +// } +// return nil; +//} +// +////上麦以加入游戏 +//- (void)upMicToJoinGame { +// NSString *position = [self findFreePosition]; +// if (position.length > 0) { +// NSString * userId = [AccountInfoStorage instance].getUid; +// UserInfoModel * userInfo = self.hostDelegate.getUserInfo; +// //清空该uid之前在队列中的信息 +// if ([self isOnMicro:userId.integerValue]) { +// if (position) { +// NSString *findOldPosition = [self findThePositionByUid:userInfo.uid]; +// NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc]init]; +// request.key = findOldPosition; +// request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; +// if (findOldPosition) { +// [[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary * _Nullable element) { +// if (error == nil) { +// NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; +// request.key = position; +// request.value = [[self userInfoToQueueExt:userInfo] toJSONString]; +// request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; +// request.transient = YES; +// [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { +// [self notifySelfInState:YES seatIndex:-1]; +// }]; +// } +// }]; +// } +// } +// }else{ +// NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; +// request.key = position; +// request.value = [[self userInfoToQueueExt:userInfo] toJSONString]; +// request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; +// request.transient = YES; +// [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { +// [self notifySelfInState:YES seatIndex:-1]; +// }]; +// } +// } +//} +// +//- (void)updateMicInfoWithGameStatus:(LittleGamePlayStatus)status { +// NSString * position = [self findThePositionByUid:[AccountInfoStorage instance].getUid.integerValue]; +// if (position != nil) { +// UserInfoModel * userInfo = self.hostDelegate.getUserInfo; +// userInfo.gameStatus = status; +// NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; +// request.key = position; +// request.value = [[self userInfoToQueueExt:userInfo] toJSONString]; +// request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; +// request.transient = YES; +// [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { +// +// }]; +// } +//} +// +///** +// * 麦位更新扩展字段。 +// */ +//- (NSDictionary *)userInfoToQueueExt:(UserInfoModel *)userInfo { +// MicroExtModel * extModel = [[MicroExtModel alloc] init]; +// extModel.gender = userInfo.gender; +// extModel.avatar = userInfo.avatar; +// extModel.uid = userInfo.uid; +// extModel.nick = userInfo.nick; +// extModel.gameStatus = userInfo.gameStatus; +// extModel.headWearUrl = userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic; +// extModel.preventKick = userInfo.userVipInfoVO.preventKick; +// extModel.enterHide = userInfo.userVipInfoVO.enterHide; +// return [extModel model2dictionary]; +//} +// +////自己是否在游戏中 +//- (BOOL)isInSudGame { +// BOOL isGamePlaying = NO; +// if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { +// for (int i = -1; i<5; i++) { +// NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; +// MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; +// if (micSequence == nil || micSequence.userInfo == nil) { +// continue; +// } +// if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { +// isGamePlaying = YES; +// break; +// } +// } +// } +// return isGamePlaying; +//} +// +////游戏状态 +//- (LittleGamePlayStatus)getCurrentUserSudGameStatus { +// LittleGamePlayStatus gameStatus = LittleGamePlayStatus_NoIn; +// for (int i = -1; i<5; i++) { +// NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; +// MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; +// if (micSequence == nil || micSequence.userInfo == nil) { +// continue; +// } +// if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { +// gameStatus = micSequence.userInfo.gameStatus; +// break; +// } +// } +// return gameStatus; +//} +// +/////下麦 +//- (void)onDownMic:(NSInteger)uid { +// if (uid == [AccountInfoStorage instance].getUid.integerValue) {//自己下麦 +// [self notifyIsPlayingState:false]; +// [self nofityPlayerPlaying:NO]; +// [self notifySetReady:false]; +// /// 下游戏麦 +// [self notifySelfInState:false seatIndex:-1]; +// } +//} +// +//#pragma mark =======ISudFSMMG Delegate======= +///** +//* 游戏日志 +//*/ +//-(void)onGameLog:(NSString*)dataJson { +// NSLog(@"ISudFSMMG:onGameLog:%@", dataJson); +// NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; +// NSString * msg_string = [dic objectForKey:@"msg"]; +// if (!msg_string) { +// return; +// } +//} +// +///** +//* 游戏开始 +//*/ +//-(void)onGameStarted { +// NSLog(@"ISudFSMMG:onGameStarted:游戏开始"); +//} +// +///** +// * 游戏销毁 +// */ +//-(void)onGameDestroyed { +// NSLog(@"ISudFSMMG:onGameDestroyed:游戏开始"); +//} +// +///** +// * Code过期 +// * @param dataJson {"code":"value"} +// */ +//-(void)onExpireCode:(id)handle dataJson:(NSString*)dataJson { +// NSLog(@"ISudFSMMG:onExpireCode:Code过期"); +// // 请求业务服务器刷新令牌 +// [Api getSudGameCode:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { +// if (code == 200) { +// NSString * gameCode = data.data[@"code"]; +// self.code = gameCode; +// [self.fsmAPP2MG updateCode:gameCode listener:^(int retCode, const NSString *retMsg, const NSString *dataJson) { +// NSLog(@"ISudFSMMG:updateGameCode retCode=%@ retMsg=%@ dataJson=%@", @(retCode), retMsg, dataJson); +// }]; +// // 回调结果 +// NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@(0), @"ret_code", @"return form APP onExpireCode", @"ret_msg", nil]; +// [handle success:[SudCommon dictionaryToJson:dict]]; +// } else { +// [XNDJTDDLoadingTool showErrorWithMessage:msg]; +// } +// } uid:[AccountInfoStorage instance].getUid]; +//} +// +///** +// * 获取游戏View信息 +// * @param handle 回调句柄 +// * @param dataJson {} +// */ +//-(void)onGetGameViewInfo:(id)handle dataJson:(NSString*)dataJson { +// CGRect rect = [[UIScreen mainScreen] bounds]; +// CGFloat scale = [[UIScreen mainScreen] nativeScale]; +// +// CGFloat top = (kNavigationHeight+105) * scale; +// CGFloat bottom; +// if (iPhoneXSeries) { +// bottom = (47+kSafeAreaBottomHeight+30 + 70) * scale; +// } else { +// bottom = (47+10+70 ) * scale; +// } +// CGFloat width = rect.size.width * scale; +// CGFloat height = rect.size.height * scale; +// NSDictionary *rectDict = [NSDictionary dictionaryWithObjectsAndKeys:@(top), @"top", @(0), @"left", @(bottom), @"bottom", @(0), @"right", nil]; +// NSDictionary *viewDict = [NSDictionary dictionaryWithObjectsAndKeys:@(width), @"width", @(height), @"height", nil]; +// NSDictionary *dataDict = [NSDictionary dictionaryWithObjectsAndKeys:@(0), @"ret_code", @"return form APP onGetGameViewInfo", @"ret_msg", viewDict, @"view_size", rectDict, @"view_game_rect", nil]; +// /// 回调 +// [handle success:[SudCommon dictionaryToJson:dataDict]]; +//} +// +///** +// * 获取游戏配置 +// * @param handle 回调句柄 +// * @param dataJson {} +// */ +//-(void)onGetGameCfg:(id)handle dataJson:(NSString*)dataJson { +// NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; +// dict[@"ret_code"] = @(0); +// dict[@"ret_msg"] = @"return form APP onGetGameCfg"; +// +// dict[@"ui"] = @{ +// @"join_btn" : @{@"custom": @(YES), @"hide": @(NO)},//加入游戏 +// @"start_btn" : @{@"custom": @(YES), @"hide": @(NO)},//开始游戏 +// @"lobby_players" : @{@"custom": @(YES), @"hide": @(NO)},//游戏中坑位点击 +// @"level" : @{@"custom": @(YES), @"hide" : @(YES)},//段位信息 +// }; +// NSString *dataJsonRet = @""; +// NSData *dataJsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil]; +// if (dataJsonData != nil) { +// dataJsonRet = [[NSString alloc]initWithData:dataJsonData encoding:NSUTF8StringEncoding]; +// } +// [handle success:dataJsonRet]; +//} +// +///** +// * 游戏状态变化 +// * @param handle 回调句柄 +// * @param state 游戏状态 +// * @param dataJson 回调json +// */ +//-(void)onGameStateChange:(id) handle state:(NSString*) state dataJson:(NSString*) dataJson { +// if ([state isEqualToString:MG_COMMON_PUBLIC_MESSAGE]) { +// NSLog(@"ISudFSMMG:onGameStateChange:游戏->APP:公屏消息"); +// } else if ([state isEqualToString:MG_COMMON_KEY_WORD_TO_HIT]) { +// NSDictionary *dic = [SudCommon turnStringToDictionary:dataJson]; +// NSString *word = [dic objectForKey:@"word"]; +// NSLog(@"ISudFSMMG:onGameStateChange:游戏->APP:你画我猜关键词获取:%@",word); +// /// 记录你画我猜关键字 +// self.DrawSomethingKeyWord = word; +// if (word == (id) [NSNull null] || [word isEqualToString:@""]) { +// /// 关闭公屏关键词hit状态 +// self.keyWordHiting = NO; +// } else { +// /// 开启公屏关键词hit状态 +// self.keyWordHiting = YES; +// } +// }else if ([state isEqualToString:MG_COMMON_SELF_CLICK_JOIN_BTN]) {//加入游戏按钮点击 +// NSDictionary *dic = [SudCommon turnStringToDictionary:dataJson]; +// int seatIndex = -1; +// if ([dic objectForKey:@"seatIndex"]) { +// seatIndex = [[dic objectForKey:@"seatIndex"] intValue]; +// } +// if (seatIndex == -1) { +// NSLog(@"来自加入按钮%d",seatIndex); +// }else { +// NSLog(@"来自麦位+入%d",seatIndex); +// } +// if ([self isOnMicro:[AccountInfoStorage instance].getUid.integerValue]) {//判断是否在麦上 +// [self notifySelfInState:YES seatIndex:seatIndex]; +// } else { +// //不在麦上 +// [self upMicToJoinGame]; +// } +// } else if([state isEqualToString:MG_COMMON_SELF_CLICK_START_BTN]) {//开始游戏按钮点击 +// [self notifyIsPlayingState:YES]; +// } else if ([state isEqualToString:MG_COMMON_SELF_CLICK_CANCEL_JOIN_BTN]) { +// /// 取消加入游戏(退出游戏按钮点击) +// [self handleSelfInExitEvent]; +// } else { +// /// 其他状态 +// NSLog(@"ISudFSMMG:onGameStateChange:游戏->APP:state:%@",MG_COMMON_PUBLIC_MESSAGE); +// } +//} +// +///** +// * 游戏玩家状态变化 +// * @param handle 回调句柄 +// * @param userId 用户id +// * @param state 玩家状态 +// * @param dataJson 回调JSON +// */ +//-(void)onPlayerStateChange:(nullable id) handle userId:(NSString*) userId state:(NSString*) state dataJson:(NSString*) dataJson { +// NSLog(@"ISudFSMMG:onPlayerStateChange:游戏->APP:游戏玩家状态变化:userId: %@ --state: %@ --dataJson: %@", userId, state, dataJson); +// /// 状态解析 +// NSString *dataStr = @""; +// if ([state isEqualToString:MG_COMMON_PLAYER_IN]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView0"); +// [self handleState_MG_COMMON_PLAYER_IN_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_COMMON_PLAYER_READY]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView1"); +// [self handleState_MG_COMMON_PLAYER_READY_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_COMMON_PLAYER_CAPTAIN]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView2"); +// [self handleState_MG_COMMON_PLAYER_CAPTAIN_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_COMMON_PLAYER_PLAYING]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView3"); +// [self handleState_MG_COMMON_PLAYER_PLAYING_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_DG_SELECTING]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView4"); +// [self handleState_MG_DG_SELECTING_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_DG_PAINTING]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView5"); +// [self handleState_MG_DG_PAINTING_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_DG_ERRORANSWER]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView6"); +// [self handleState_MG_DG_ERRORANSWER_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_DG_TOTALSCORE]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView7"); +// [self handleState_MG_DG_TOTALSCORE_WithUserId:userId dataJson:dataJson]; +// } else if ([state isEqualToString:MG_DG_SCORE]) { +// dataStr = YMLocalizedString(@"XPRoomLittleGameContainerView8"); +// [self handleState_MG_DG_SCORE_WithUserId:userId dataJson:dataJson]; +// }else { +// NSLog(@"ISudFSMMG:onPlayerStateChange:未做解析状态:%@", MG_DG_SCORE); +// } +// NSLog(@"ISudFSMMG:onPlayerStateChange:dataStr:%@", dataStr); +// /// 回调 +// NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@(0), @"ret_code", @"return form APP onPlayerStateChange", @"ret_msg", nil]; +// [handle success:[SudCommon dictionaryToJson:dict]]; +//} +// +///// 退出游戏 +//- (void)handleSelfInExitEvent { +// if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { +// return; +// } +// /// 正在游戏中,只退出游戏 +// if ([self getCurrentUserSudGameStatus] == LittleGamePlayStatus_Plying) { +// [self notifyIsPlayingState:false]; +// [self nofityPlayerPlaying:NO]; +// [self notifySetReady:false]; +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; +// } else if ([self getCurrentUserSudGameStatus] == LittleGamePlayStatus_Ready) { /// 非游戏状态下 +// /// 如果已经准备先退出准备状态 +// [self notifySetReady:false]; +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; +// } else { +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; +// } +// /// 下游戏麦 +// [self notifySelfInState:false seatIndex:-1]; +//} +// +///// 准备游戏 +//- (void)handleSelfReadyEvent { +// [self notifySetReady:true]; +//} +// +///// 取消准备 +//- (void)handleSelfCancelReadyEvent { +// [self notifySetReady:false]; +//} +// +///// 开始游戏 +//- (void)handleGameStartEvent { +// [self notifyIsPlayingState:YES]; +//} +// +//#pragma mark =======APP->游戏状态处理======= +///// 状态通知(app to mg) +///// @param state 状态名称 +///// @param dataJson 需传递的json +//- (void)notifyStateChange:(NSString *) state dataJson:(NSString*) dataJson { +// [self.fsmAPP2MG notifyStateChange:state dataJson:dataJson listener:^(int retCode, const NSString *retMsg, const NSString *dataJson) { +// NSLog(@"ISudFSMMG:notifyStateChange:retCode=%@ retMsg=%@ dataJson=%@", @(retCode), retMsg, dataJson); +// RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; +// if (retCode == 0 && [state isEqualToString:APP_COMMON_SELF_PLAYING]) {//开始游戏 +// //上报游戏开始 +// NSString *mgid = [NSString stringWithFormat:@"%lld", self.currentmgId]; +// if (mgid.length <= 0) { +// return; +// } +// [Api startGameCheck:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { +// if (code != 200) { +// [XNDJTDDLoadingTool showErrorWithMessage:msg]; +// } +// } roomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid] mgId:mgid]; +// } else if (retCode == 0 && [state isEqualToString:APP_COMMON_SELF_END]) {//结束游戏 +// +// } +// }]; +//} +// +///// 加入,退出游戏 +///// @param isIn YES:加入 NO:退出 +//- (void)notifySelfInState:(BOOL)isIn uid:(NSInteger)uid { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isIn), @"isIn", @(1), @"teamId", nil]; +// [self notifyStateChange:APP_COMMON_SELF_IN dataJson:[SudCommon dictionaryToJson:dic]]; +//} +// +///// 加入,退出游戏 +///// @param isIn YES:加入 NO:退出 +//- (void)notifySelfInState:(BOOL)isIn seatIndex:(int)seatIndex { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(seatIndex), @"seatIndex", @(isIn), @"isIn", @(1), @"teamId", nil]; +// [self notifyStateChange:APP_COMMON_SELF_IN dataJson:[SudCommon dictionaryToJson:dic]]; +//} +// +///// 踢出用户 +///// @param userId 踢出用户id +//- (void)notifyKickStateWithUserId:(NSString *)userId { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:userId, @"kickedUID", nil]; +// [self notifyStateChange:APP_COMMON_SELF_KICK dataJson:[SudCommon dictionaryToJson:dic]]; +//} +// +///// 设置用户为队长 +///// @param userId 被设置用户id +//- (void)notifySetCaptainStateWithUserId:(NSString *)userId { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:userId, @"curCaptainUID", nil]; +// [self notifyStateChange:APP_COMMON_SELF_CAPTAIN dataJson:[SudCommon dictionaryToJson:dic]]; +//} +// +///// 命中 关键词状态 (你画我猜) +//- (void)notifyChangeTextHitState:(NSString *)keyWord { +// if([keyWord isKindOfClass:[NSNull class]])return; +// if (keyWord.length && [keyWord containsString:self.DrawSomethingKeyWord]) { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(true), @"isHit", self.DrawSomethingKeyWord, @"keyWord", self.DrawSomethingKeyWord, @"text", nil]; +// [self notifyStateChange:APP_COMMON_SELF_TEXT_HIT dataJson:[SudCommon dictionaryToJson:dic]]; +// } +//} +// +///// 是否设置为准备状态 +//- (void)notifySetReady:(BOOL)isReady { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isReady), @"isReady", nil]; +// [self notifyStateChange:APP_COMMON_SELF_READY dataJson:[SudCommon dictionaryToJson:dic]]; +//} +// +///// 停止游戏状态设置 +//- (void)notifySetEnd { +// [self notifyStateChange:APP_COMMON_SELF_END dataJson:[SudCommon dictionaryToJson:@{}]]; +//} +// +///// 游戏中状态设置 +//- (void)notifyIsPlayingState:(BOOL)isPlaying { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isPlaying), @"isPlaying", nil]; +// [self notifyStateChange:APP_COMMON_SELF_PLAYING dataJson:[SudCommon dictionaryToJson:dic]]; +//} +// +/////游戏中退出游戏 +//- (void)nofityPlayerPlaying:(BOOL)isPlaying { +// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@(isPlaying), @"isPlaying", nil]; +// [self notifyStateChange:MG_COMMON_PLAYER_PLAYING dataJson:[SudCommon dictionaryToJson:dic]]; +//} +// +//#pragma mark =======游戏->APP状态处理======= +//- (void)handleState_MG_COMMON_PLAYER_IN_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; +// /// 加入状态:YES加入,NO退出 +// BOOL isIn = NO; +// if (dic) { +// NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; +// if (retCode != 0) { +// return; +// } +// isIn = [[dic objectForKey:@"isIn"] boolValue]; +// } +// if ([userId isEqualToString:[AccountInfoStorage instance].getUid]) {//是当前用户 +// if (isIn) {//加入了游戏 +// //判断是否在麦上 +// if ([self isOnMicro:[userId longLongValue]]) { +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_IsIn]; +// } else {//不在麦上 +// [self upMicToJoinGame]; +// } +// //判断是否为房主,房主需要设为队长 +// if (self.hostDelegate.getRoomInfo.uid == userId.integerValue) { +// [self notifySetCaptainStateWithUserId:userId]; +// } +// self.sudGameStatus = LittleGamePlayStatus_IsIn; +// }else {//退出了游戏 +// //判断是否在麦上 +// if ([self isOnMicro:[userId longLongValue]]) { +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_NoIn]; +// } +// self.sudGameStatus = LittleGamePlayStatus_NoIn; +// } +// } else {//退出游戏 +// if (self.sudGameStatus == LittleGamePlayStatus_Plying) {//游戏进行中,用户退出 +// ///自己是公会超管 +// BOOL meIsSuperAdmin = NO; +// for (GuildSuperAdminInfoModel *managerInfo in self.hostDelegate.getRoomSuperAdminList) { +// if ([managerInfo.uid isEqualToString:[AccountInfoStorage instance].getUid]) { +// meIsSuperAdmin = YES; +// break; +// } +// } +// NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; +// request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; +// request.userIds = @[[AccountInfoStorage instance].getUid]; +// [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { +// if (error == nil) { +// NIMChatroomMember *member = members.firstObject; +// if (member.type == NIMChatroomMemberTypeManager || member.type == NIMChatroomMemberTypeCreator || meIsSuperAdmin) { +// NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; +// request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; +// request.userIds = @[userId]; +// [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { +// if (error == nil) { +// NIMChatroomMember *member = members.firstObject; +// [XNDJTDDLoadingTool showErrorWithMessage:[NSString stringWithFormat:YMLocalizedString(@"XPRoomLittleGameContainerView9"), member.roomNickname]]; +// } +// }]; +// } +// } +// }]; +// +// } +// } +//} +// +//- (void)handleState_MG_COMMON_PLAYER_READY_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// /// 玩家是否准备,YES:已准备,NO:未准备 +// BOOL isReady = NO; +// NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; +// if (dic) { +// NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; +// if (retCode != 0) { +// return; +// } +// isReady = [[dic objectForKey:@"isReady"] boolValue]; +// } +// if ([userId isEqualToString:[AccountInfoStorage instance].getUid]) { +// if (isReady) { +// //判断是否在麦上 +// if ([self isOnMicro:[userId longLongValue]]) { +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_Ready]; +// } +// self.sudGameStatus = LittleGamePlayStatus_Ready; +// }else { +// if ([self isOnMicro:[userId longLongValue]]) { +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_IsIn]; +// } +// self.sudGameStatus = LittleGamePlayStatus_IsIn; +// } +// } +//} +// +//- (void)handleState_MG_COMMON_PLAYER_CAPTAIN_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// /// 是否是队长:YES:是队长 NO:不是队长 +// BOOL isCaptain = NO; +// NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; +// if (dic) { +// /// 错误处理 +// NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; +// if (retCode != 0) { +// return; +// } +// isCaptain = [[dic objectForKey:@"isCaptain"] boolValue]; +// } +//} +// +//- (void)handleState_MG_COMMON_PLAYER_PLAYING_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// /// 是否正在游戏中 +// BOOL isPlaying = NO; +// NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; +// if (dic) { +// /// 错误处理 +// NSInteger retCode = [[dic objectForKey:@"retCode"] integerValue]; +// if (retCode != 0) { +// return; +// } +// isPlaying = [[dic objectForKey:@"isPlaying"] boolValue]; +// } +// if ([userId isEqualToString:[AccountInfoStorage instance].getUid]) { +// if (isPlaying) { +// //判断是否在麦上 +// if ([self isOnMicro:[userId longLongValue]]) { +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_Plying]; +// } +// if (self.delegate && [self.delegate respondsToSelector:@selector(hiddenSudGamePostionView)]) { +// [self.delegate hiddenSudGamePostionView]; +// } +// self.sudGameStatus = LittleGamePlayStatus_Plying; +// }else { +// if ([self isOnMicro:[userId longLongValue]]) { +// [self updateMicInfoWithGameStatus:LittleGamePlayStatus_IsIn]; +// } +// self.sudGameStatus = LittleGamePlayStatus_IsIn; +// } +// } +//} +// +//- (void)handleState_MG_DG_SELECTING_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// NSLog(@"handleState_MG_DG_SELECTING_WithUserId%@",dataJson); +//} +// +//- (void)handleState_MG_DG_PAINTING_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// NSLog(@"handleState_MG_DG_PAINTING_WithUserId%@",dataJson); +// /// 设置麦位状态为作画中 +// NSDictionary * dic = [SudCommon turnStringToDictionary:dataJson]; +// bool isPainting = NO; +// if (dic) { +// isPainting = [dic[@"isPainting"] boolValue]; +// } +//} +// +//- (void)handleState_MG_DG_ERRORANSWER_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// /// 错误答案 +// NSLog(@"handleState_MG_DG_ERRORANSWER_WithUserId%@",dataJson); +// +//} +// +//- (void)handleState_MG_DG_TOTALSCORE_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// /// 总积分 +// NSLog(@"handleState_MG_DG_TOTALSCORE_WithUserId%@",dataJson); +//} +// +//- (void)handleState_MG_DG_SCORE_WithUserId:(NSString *)userId dataJson:(NSString *)dataJson { +// /// 本次积分 +// NSLog(@"handleState_MG_DG_SCORE_WithUserId%@",dataJson); +//} +// +///// 销毁MG +//- (void)destroyMG { +// if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { +// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ +// [self.fsmAPP2MG destroyMG]; +// }); +// } +//} +// +//#pragma mark - RoomGuestDelegate +//- (void)onRoomEntered { +// if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { +// self.hidden = YES; +// return; +// } else { +// self.hidden = NO; +// } +// [self updateSudGame]; +//} +// +//- (void)onRoomUpdate { +// if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { +// self.hidden = YES; +// [self.fsmAPP2MG destroyMG]; +// } else { +// self.hidden = NO; +// } +// [self updateSudGame]; +//} +//#pragma mark - RoomGuestDelegate +//- (void)handleNIMCustomMessage:(NIMMessage *)message { +// if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { +// return; +// } +// NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; +// if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { +// AttachmentModel *attachment = (AttachmentModel *)obj.attachment; +// if (attachment.first == CustomMessageType_Kick_User) { +// XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; +// [self onDownMic:kickModel.uid]; +// } else if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Kick) { +// XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; +// [self onDownMic:kickModel.uid]; +// } +// } +//} +// +//- (void)handleNIMNotificationMessage:(NIMMessage *)message { +// if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) {return;} +// NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; +// NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; +// switch (content.eventType) { +// case NIMChatroomEventTypeQueueChange: // 麦序上下麦 +// { +// NSDictionary* data = (NSDictionary *)content.ext; +// UserInfoModel* userInfo = [UserInfoModel modelWithJSON:[data objectForKey:NIMChatroomEventInfoQueueChangeItemValueKey]]; +// NSInteger changeType = [data[NIMChatroomEventInfoQueueChangeTypeKey] integerValue]; +// if (changeType != 1) { +// [self onDownMic:userInfo.uid]; +// } +// } +// break; +// default: +// break; +// } +//} +// +//- (void)handleNIMTextMessage:(NIMMessage *)message { +// if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) {return;} +// if (message.from.integerValue == [AccountInfoStorage instance].getUid.integerValue && [self isInSudGame]) { +// [self notifyChangeTextHitState:message.text]; +// } +//} @end diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index 9ca8a9c6..33453903 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -3272,3 +3272,10 @@ "MSRoomGameQuitGameView0"="游戏已经开始,退出房间将默认 游戏失败,确认退出房间?"; "MSRoomGameQuitGameView1"="退出"; "MSRoomGameQuitGameView2"="继续游戏"; +//MSRoomGameHeadView +"MSRoomGameHeadView0"="匹配中"; +"MSRoomGameHeadView1"="匹配成功"; +"MSRoomGameHeadView2"="获胜奖励%@金币"; + +//MSRoomGameVC +"MSRoomGameVC0"="匹配失败"; diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index 1f08e566..d1e3a300 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -3257,11 +3257,4 @@ ///MSRoomSetingBackdropCell "MSRoomSetingBackdropCell0"="使用中"; "MSRoomSetingBackdropCell1"="確認選擇這張圖片作為房間主題嗎?"; -///MSTabbarBeginGameView -"MSTabbarBeginGameView0"="開始"; -///MSRoomGameVictoryView -"MSRoomGameVictoryView0"="重新匹配"; -///MSRoomGameQuitGameView -"MSRoomGameQuitGameView0"="遊戲已經開始,退出房間將默認 遊戲失敗,確認退出房間?"; -"MSRoomGameQuitGameView1"="退出"; -"MSRoomGameQuitGameView2"="繼續遊戲"; +