PK面板麦序的显示
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#import "RtcManager.h"
|
||||
#import "XPRoomMiniManager.h"
|
||||
#import "Api+RoomPK.h"
|
||||
#import "XPGiftStorage.h"
|
||||
///Model
|
||||
#import "RoomInfoModel.h"
|
||||
#import "MicroQueueModel.h"
|
||||
@@ -42,6 +43,9 @@
|
||||
#import "AcrossRoomPKPanelModel.h"
|
||||
#import "RoomPKDetailInfoModel.h"
|
||||
#import "RoomPKChooseUserModel.h"
|
||||
#import "GiftReceiveInfoModel.h"
|
||||
#import "GiftInfoModel.h"
|
||||
#import "RoomPKTeamModel.h"
|
||||
///View
|
||||
#import "XPRoomHalfWebView.h"
|
||||
#import "XPAnchorAudienceUpMicView.h"
|
||||
@@ -118,6 +122,18 @@
|
||||
@property (nonatomic,strong) XPRoomPKProgressView *roompkPanelView;
|
||||
///房间PK信息
|
||||
@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo;
|
||||
///红队按礼物价值计算的话分数
|
||||
@property (nonatomic,assign) CGFloat redTeamValueScore;
|
||||
///蓝队总的分数按礼物价值计算的话分数
|
||||
@property (nonatomic,assign) CGFloat blueTeamValueScore;
|
||||
///红队收到礼物个数(按照收礼个数)
|
||||
@property (nonatomic, strong) NSMutableSet * redTeamGiftPersonDic;
|
||||
///蓝队收到礼物个数(按照收礼个数)
|
||||
@property (nonatomic, strong) NSMutableSet * blueTeamGiftPersonDic;
|
||||
///红队的人员
|
||||
@property (nonatomic,strong) NSArray *redUserArray;
|
||||
///蓝队的人员
|
||||
@property (nonatomic,strong) NSArray *blueUserArray;
|
||||
@end
|
||||
|
||||
@implementation XPRoomFunctionContainerView
|
||||
@@ -323,6 +339,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (MicroQueueModel *)findMicroInfoByUid:(NSString *)uid {
|
||||
for (MicroQueueModel *model in self.delegate.getMicroQueue.allValues) {
|
||||
if (model.userInfo && model.userInfo.uid == uid.intValue) {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)getRoomPKDetailInfo {
|
||||
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
|
||||
if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
|
||||
@@ -331,34 +356,68 @@
|
||||
RoomPKDetailInfoModel * pkDetailInfo = [RoomPKDetailInfoModel modelWithDictionary:data.data];
|
||||
self.pkDetailInfo = pkDetailInfo;
|
||||
self.roompkPanelView.pkDetailInfo = pkDetailInfo;
|
||||
if (self.pkDetailInfo.roomPK.pkStatus != RoomPKStatusType_Playing) {
|
||||
NSMutableArray * redArray = [NSMutableArray array];
|
||||
NSMutableArray * blueArray = [NSMutableArray array];
|
||||
NSMutableDictionary * queue = self.delegate.getMicroQueue;
|
||||
[self.roompkPanelView startRoomPKCountDown:(pkDetailInfo.roomPK.endTime - pkDetailInfo.now) / 1000];
|
||||
NSMutableDictionary * queue = self.delegate.getMicroQueue;
|
||||
///配置一下麦序的信息
|
||||
NSMutableArray * redArray = [NSMutableArray array];
|
||||
NSMutableArray * blueArray = [NSMutableArray array];
|
||||
if (pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_Playing) {
|
||||
for (int i = 0; i < pkDetailInfo.roomPK.teams.count; i++) {
|
||||
RoomPKTeamModel * teamInfo = [pkDetailInfo.roomPK.teams objectAtIndex:i];
|
||||
if (teamInfo.team == GroupTyp_Red) {
|
||||
for (int i = 0; i < teamInfo.teamMembers.count; i++) {
|
||||
RoomPKTeamUserModel * teamUserModel = [teamInfo.teamMembers objectAtIndex:i];
|
||||
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
redInfo.avatar = teamUserModel.avatar;
|
||||
redInfo.uid = teamUserModel.uid;
|
||||
redInfo.groupType = GroupTyp_Red;
|
||||
redInfo.position = [self findMicroInfoByUid:teamUserModel.uid].microState.position;
|
||||
redInfo.nick = teamUserModel.nick;
|
||||
[redArray addObject:redInfo];
|
||||
}
|
||||
} else if(teamInfo.team == GroupType_Blue) {
|
||||
for (int i = 0; i < teamInfo.teamMembers.count; i++) {
|
||||
RoomPKTeamUserModel * teamUserModel = [teamInfo.teamMembers objectAtIndex:i];
|
||||
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
blueInfo.avatar = teamUserModel.avatar;
|
||||
blueInfo.uid = teamUserModel.uid;
|
||||
blueInfo.groupType = GroupType_Blue;
|
||||
blueInfo.position = [self findMicroInfoByUid:teamUserModel.uid].microState.position;
|
||||
blueInfo.nick = teamUserModel.nick;
|
||||
[blueArray addObject:blueInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0 ; i < queue.allValues.count; i++) {
|
||||
MicroQueueModel * micModel = [queue.allValues objectAtIndex:i];
|
||||
if (micModel.userInfo && micModel.userInfo.uid > 0) {
|
||||
UserInfoModel * userInfo = micModel.userInfo;
|
||||
if (userInfo.groupType == GroupTyp_Red) {
|
||||
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
redInfo.userUrl = userInfo.avatar;
|
||||
redInfo.avatar = userInfo.avatar;
|
||||
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
redInfo.groupType = userInfo.groupType;
|
||||
redInfo.position = micModel.microState.position;
|
||||
redInfo.nick = userInfo.nick;
|
||||
[redArray addObject:redInfo];
|
||||
} else if(userInfo.groupType == GroupType_Blue) {
|
||||
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
blueInfo.userUrl = userInfo.avatar;
|
||||
blueInfo.avatar = userInfo.avatar;
|
||||
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
blueInfo.groupType = userInfo.groupType;
|
||||
blueInfo.position = micModel.microState.position;
|
||||
blueInfo.nick = userInfo.nick;
|
||||
[blueArray addObject:blueInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
self.roompkPanelView.redChooseArray = redArray.copy;
|
||||
self.roompkPanelView.blueChooseArray = blueArray.copy;
|
||||
|
||||
}
|
||||
self.redUserArray = redArray.copy;
|
||||
self.blueUserArray = blueArray.copy;
|
||||
self.roompkPanelView.redChooseArray = self.redUserArray;
|
||||
self.roompkPanelView.blueChooseArray = self.blueUserArray;
|
||||
} else {
|
||||
[XCHUDTool showErrorWithMessage:msg];
|
||||
}
|
||||
@@ -366,6 +425,142 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)roomPKReceiveGift:(AttachmentModel *)attachment {
|
||||
if (self.delegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode && self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_Playing) {
|
||||
GiftReceiveInfoModel *giftReceiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
|
||||
GiftInfoModel *giftInfo = giftReceiveInfo.gift == nil ? giftReceiveInfo.giftInfo : giftReceiveInfo.gift;
|
||||
if (giftInfo == nil) {
|
||||
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:giftReceiveInfo.giftId];
|
||||
}
|
||||
if (attachment.first == CustomMessageType_AllMicroSend) {
|
||||
if (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroSend) {///普通礼物
|
||||
if (self.pkDetailInfo.roomPK.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
|
||||
NSArray *targetUids = [giftReceiveInfo.targetUsers valueForKeyPath:@"uid"];
|
||||
[self canculeRoomPKSendGiftNumPerson:targetUids];
|
||||
} else {
|
||||
[self canculeRoomGiftValueReceiveInfo:giftReceiveInfo giftPrice:giftInfo.goldPrice giftNumber:giftReceiveInfo.giftNum];
|
||||
}
|
||||
} else if(attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend) {///福袋礼物
|
||||
if (giftReceiveInfo.luckyGiftList) {
|
||||
__block NSInteger goldPrice = 0;
|
||||
[giftReceiveInfo.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
GiftInfoModel *giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
|
||||
goldPrice += giftInfo.goldPrice * giftListInfo.giftNum;
|
||||
}];
|
||||
if (self.pkDetailInfo.roomPK.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
|
||||
NSArray *targetUids = @[giftReceiveInfo.targetUid];
|
||||
[self canculeRoomPKSendGiftNumPerson:targetUids];
|
||||
} else {
|
||||
[self canculeRoomGiftValueReceiveInfo:giftReceiveInfo giftPrice:goldPrice giftNumber:1];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(attachment.first == CustomMessageType_Gift) {
|
||||
if (attachment.second == Custom_Message_Sub_Gift_LuckySend) {
|
||||
__block NSInteger goldPrice = 0;
|
||||
[giftReceiveInfo.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
GiftInfoModel *giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
|
||||
goldPrice += giftInfo.goldPrice * giftListInfo.giftNum;
|
||||
}];
|
||||
if (self.pkDetailInfo.roomPK.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
|
||||
NSArray *targetUids = @[[NSString stringWithFormat:@"%ld", giftReceiveInfo.luckyGiftList.user.uid]];
|
||||
[self canculeRoomPKSendGiftNumPerson:targetUids];
|
||||
} else {
|
||||
[self canculeRoomGiftValueReceiveInfo:giftReceiveInfo giftPrice:goldPrice giftNumber:giftReceiveInfo.giftNum];
|
||||
}
|
||||
} else {
|
||||
if (self.pkDetailInfo.roomPK.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
|
||||
NSArray *targetUids = @[giftReceiveInfo.targetUid];
|
||||
[self canculeRoomPKSendGiftNumPerson:targetUids];
|
||||
} else {
|
||||
[self canculeRoomGiftValueReceiveInfo:giftReceiveInfo giftPrice:giftInfo.goldPrice giftNumber:giftReceiveInfo.giftNum];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)canculeRoomGiftValueReceiveInfo:(GiftReceiveInfoModel *)giftReceiveInfo giftPrice:(NSInteger)giftPrice giftNumber:(NSInteger)giftNumber {
|
||||
//是不是全麦送礼
|
||||
if (giftReceiveInfo.targetUids.count > 0) {
|
||||
for (RoomPKChooseUserModel * userInfo in self.redUserArray) {
|
||||
for (NSString * uid in giftReceiveInfo.targetUids) {
|
||||
if (uid.integerValue == userInfo.uid.integerValue) {
|
||||
self.redTeamValueScore += (giftPrice * giftNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if (giftReceiveInfo.targetUsers.count > 0){//多选
|
||||
NSArray *targetUids = [giftReceiveInfo.targetUsers valueForKeyPath:@"uid"];
|
||||
for (RoomPKChooseUserModel * userInfo in self.redUserArray) {
|
||||
for (NSString * uid in targetUids) {
|
||||
if (uid.integerValue == userInfo.uid.integerValue) {
|
||||
self.redTeamValueScore += (giftPrice * giftNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for (RoomPKChooseUserModel * userInfo in self.redUserArray) {
|
||||
if (userInfo.uid.integerValue == giftReceiveInfo.targetUid.integerValue) {
|
||||
self.redTeamValueScore += (giftPrice *giftNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//是不是全麦
|
||||
if (giftReceiveInfo.targetUids.count > 0) {
|
||||
for (RoomPKChooseUserModel * infor in self.blueUserArray) {
|
||||
for (NSString * uid in giftReceiveInfo.targetUids) {
|
||||
if (uid.integerValue == infor.uid.integerValue) {
|
||||
self.blueTeamValueScore += (giftPrice * giftNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if (giftReceiveInfo.targetUsers.count > 0){//多选
|
||||
NSArray *targetUids = [giftReceiveInfo.targetUsers valueForKeyPath:@"uid"];
|
||||
for (RoomPKChooseUserModel * infor in self.blueUserArray) {
|
||||
for (NSString * uid in targetUids) {
|
||||
if (uid.integerValue == infor.uid.integerValue) {
|
||||
self.blueTeamValueScore += (giftPrice * giftNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for (RoomPKChooseUserModel * infor in self.blueUserArray) {
|
||||
if (infor.uid.integerValue == giftReceiveInfo.targetUid.integerValue) {
|
||||
self.blueTeamValueScore += (giftPrice * giftNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
[self.roompkPanelView configRedTeamScore:self.redTeamValueScore blueTeamScore:self.blueTeamValueScore];
|
||||
}
|
||||
|
||||
- (void)canculeRoomPKSendGiftNumPerson:(NSArray *)sendGiftUses {
|
||||
for (NSString * uid in sendGiftUses) {
|
||||
for (int i = 0; i < self.redUserArray.count; i++) {
|
||||
RoomPKChooseUserModel * redUserInfo = [self.redUserArray objectAtIndex:i];
|
||||
if (uid.integerValue == redUserInfo.uid.integerValue) {
|
||||
[self.redTeamGiftPersonDic addObject:uid];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < self.blueUserArray.count; i++) {
|
||||
RoomPKChooseUserModel * redUserInfo = [self.blueUserArray objectAtIndex:i];
|
||||
if (uid.integerValue == redUserInfo.uid.integerValue) {
|
||||
[self.blueTeamGiftPersonDic addObject:uid];
|
||||
}
|
||||
}
|
||||
}
|
||||
[self.roompkPanelView configRedTeamScore:self.redTeamGiftPersonDic.count blueTeamScore:self.blueTeamGiftPersonDic.count];
|
||||
}
|
||||
|
||||
#pragma mark - RoomGuestDelegate
|
||||
- (void)onRoomUpdate {
|
||||
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
|
||||
@@ -514,14 +709,16 @@
|
||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||
if (attachment.first == CustomMessageType_AnchorRoom_AudienceUpMic) {
|
||||
[self showAskForUpMic:attachment.data];
|
||||
} else if(attachment.first == CustomMessageType_Gift && (attachment.second == Custom_Message_Sub_Gift_Send || attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_Gift_ChannelNotify)) {
|
||||
[self roomPKReceiveGift:attachment];
|
||||
}else if(attachment.first == CustomMessageType_AllMicroSend && (attachment.second == Custom_Message_Sub_AllMicroSend || attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend)) {
|
||||
[self roomPKReceiveGift:attachment];
|
||||
} else if(attachment.first == CustomMessageType_Room_PK) {
|
||||
if (attachment.second == Custom_Message_Sub_Room_PK_Start) {
|
||||
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
self.roompkPanelView.pkDetailInfo = self.pkDetailInfo;
|
||||
[self.roompkPanelView startRoomPKCountDown:pkInfo.duration];
|
||||
if (pkInfo.pkStatus == RoomPKStatusType_Playing) {
|
||||
//TODO: 弹框显示Pk
|
||||
}
|
||||
}else if (attachment.second == Custom_Message_Sub_Room_PK_Mode_Open){
|
||||
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
@@ -534,10 +731,14 @@
|
||||
[self.roompkPanelView stopRoomPKCountDown];
|
||||
if (pkInfo.pkStatus == RoomPKStatusType_ReStart) {///重新开始了 需要重新赋值
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
self.roompkPanelView.pkDetailInfo = self.pkDetailInfo;
|
||||
} else {
|
||||
if (pkInfo.pkId == self.pkDetailInfo.roomPK.pkId) {
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
self.roompkPanelView.pkDetailInfo = self.pkDetailInfo;
|
||||
//TODO: 更新自己的麦序结果
|
||||
} else {
|
||||
[self.roompkPanelView clearRoomPKTeamData];
|
||||
}
|
||||
}
|
||||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Close) {
|
||||
@@ -833,14 +1034,16 @@
|
||||
UserInfoModel * userInfo = micModel.userInfo;
|
||||
if (userInfo.groupType == GroupTyp_Red) {
|
||||
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
redInfo.userUrl = userInfo.avatar;
|
||||
redInfo.avatar = userInfo.avatar;
|
||||
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
redInfo.nick = userInfo.nick;
|
||||
redInfo.groupType = userInfo.groupType;
|
||||
redInfo.position = micModel.microState.position;
|
||||
[redArray addObject:redInfo];
|
||||
} else if(userInfo.groupType == GroupType_Blue) {
|
||||
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
blueInfo.userUrl = userInfo.avatar;
|
||||
blueInfo.avatar = userInfo.avatar;
|
||||
blueInfo.nick = userInfo.nick;
|
||||
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
blueInfo.groupType = userInfo.groupType;
|
||||
blueInfo.position = micModel.microState.position;
|
||||
@@ -848,8 +1051,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
self.roompkPanelView.redChooseArray = redArray.copy;
|
||||
self.roompkPanelView.blueChooseArray = blueArray.copy;
|
||||
self.redUserArray = redArray.copy;
|
||||
self.blueUserArray = blueArray.copy;
|
||||
self.roompkPanelView.redChooseArray = self.redUserArray;
|
||||
self.roompkPanelView.blueChooseArray = self.blueUserArray;
|
||||
}
|
||||
} else {
|
||||
[self getRoomPKDetailInfo];
|
||||
|
Reference in New Issue
Block a user