房间PK的公屏显示和更新麦序
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
#import "RoomFaceInfoModel.h"
|
||||
#import "RoomFaceSendInfoModel.h"
|
||||
#import "GuildSuperAdminInfoModel.h"
|
||||
#import "RoomPKChooseUserModel.h"
|
||||
#import "RoomPKInfoModel.h"
|
||||
|
||||
#import "NetImageView.h"
|
||||
|
||||
@@ -99,6 +101,8 @@
|
||||
} else if(first == CustomMessageType_Hall_Super_Admin) {///超管踢人出房间
|
||||
XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data];
|
||||
return [self createKickUserAttribute:attachment info:kickModel];
|
||||
} else if (first == CustomMessageType_Room_PK) {///房内PK
|
||||
return [self createRoomPKAttribute:attachment];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -250,6 +254,115 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - 房间内PK
|
||||
- (NSAttributedString *)createRoomPKAttribute:(AttachmentModel *)attachment {
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
if (attachment.second == Custom_Message_Sub_Room_PK_Manager_Up_Mic) {
|
||||
[attribute appendAttributedString:[self createTextAttribute:@"管理员邀请" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
for (NSDictionary * selectuUser in [attachment.data allValues]) {
|
||||
RoomPKChooseUserModel * userInfoModel = [RoomPKChooseUserModel modelWithDictionary:selectuUser];
|
||||
if (userInfoModel.groupType != GroupType_default && userInfoModel.nick.length > 0) {
|
||||
[attribute appendAttributedString:[self createNickAtrribute:userInfoModel.nick uid:userInfoModel.uid.integerValue]];
|
||||
[attribute appendAttributedString:[self createTextAttribute:@"进入" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
NSString * groupTypeStr;
|
||||
UIColor * groupColor;
|
||||
if (userInfoModel.groupType == GroupTyp_Red) {
|
||||
groupTypeStr= @"红队";
|
||||
groupColor = UIColorFromRGB(0xFB3D74);
|
||||
}else{
|
||||
groupTypeStr = @"蓝队";
|
||||
groupColor = UIColorFromRGB(0x3291FC);
|
||||
}
|
||||
[attribute appendAttributedString:[self createTextAttribute:groupTypeStr color:groupColor font:kRoomMessageDefalutFont]];
|
||||
[attribute appendAttributedString:[self createTextAttribute:@"," color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
}
|
||||
}
|
||||
[attribute deleteCharactersInRange:NSMakeRange(attribute.string.length - 1, 1)];
|
||||
} else {
|
||||
RoomPKInfoModel * model = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||||
if (attachment.second == Custom_Message_Sub_Room_PK_Mode_Close) {
|
||||
NSString * title = @"管理员关闭了PK模式";
|
||||
[attribute appendAttributedString:[self createTextAttribute:title color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
NSRange range = [title rangeOfString:@"关闭了"];
|
||||
[attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor messageDefaultTextColor] range:range];
|
||||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Result) {
|
||||
NSString * victoryStr;
|
||||
if (model.result == RoomPKResultType_Draw) {
|
||||
RoomPKTeamModel * team = [model.teams firstObject];
|
||||
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
|
||||
victoryStr = @"平局";
|
||||
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
|
||||
NSString * result = [NSString stringWithFormat:@"本场PK结果:%@!\n PK值%@",victoryStr, resultScale];
|
||||
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor mainTextColor] font:kRoomMessageDefalutFont]];
|
||||
}else{
|
||||
if (team.protecScore > 0) {
|
||||
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
|
||||
victoryStr = @"平局";
|
||||
NSString * result = [NSString stringWithFormat:@"本场PK结果:%@!\n PK值%@",victoryStr, resultScale];
|
||||
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor mainTextColor] font:kRoomMessageDefalutFont]];
|
||||
}else{
|
||||
victoryStr = @"平局";
|
||||
NSString * result = [NSString stringWithFormat:@"本场PK结果:%@!\n PK值%@",victoryStr, @"0:0"];
|
||||
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor mainTextColor] font:kRoomMessageDefalutFont]];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
RoomPKTeamModel * victoryTeam;
|
||||
RoomPKTeamModel * failTeam;
|
||||
for (int i = 0 ; i < model.teams.count; i++) {
|
||||
RoomPKTeamModel * team = [model.teams objectAtIndex:i];
|
||||
if (team.team == (GroupType)model.result) {
|
||||
victoryTeam = team;
|
||||
}else{
|
||||
failTeam = team;
|
||||
}
|
||||
}
|
||||
|
||||
if (model.result == RoomPKResultType_Red){
|
||||
victoryStr = @"红队胜利";
|
||||
}else if (model.result == RoomPKResultType_Blue){
|
||||
victoryStr = @"蓝队胜利";
|
||||
}
|
||||
|
||||
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", victoryTeam.score],[NSString stringWithFormat:@"%lld", failTeam.score]];
|
||||
NSString * result;
|
||||
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
|
||||
result = [NSString stringWithFormat:@"本场PK结果:%@!\n PK值%@ \n 胜利方战斗值:%@",victoryStr, resultScale,[NSNumber numberWithLongLong:victoryTeam.score]];
|
||||
}else{
|
||||
if (victoryTeam.protector) {
|
||||
result = [NSString stringWithFormat:@"本场PK结果:%@ \n PK值%@ \n 胜利方战斗值:%@ \n 守护者:%@ \n 守护值:%@",victoryStr, resultScale,[[NSNumber numberWithLongLong:victoryTeam.score] stringValue],victoryTeam.protector.nick.length > 0 ?victoryTeam.protector.nick : @"", [[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
|
||||
}else{
|
||||
result = [NSString stringWithFormat:@"本场PK结果:%@ \n PK值%@ \n 胜利方战斗值:%@ \n 守护值:%@",victoryStr, resultScale,[[NSNumber numberWithLongLong:victoryTeam.score] stringValue], [[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
|
||||
}
|
||||
}
|
||||
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
}
|
||||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Open) {
|
||||
NSString * pkType;
|
||||
if (model.voteMode == RoomPKVoteModeType_GiftValue) {
|
||||
pkType = @"获得礼物多的团队获胜";
|
||||
}else if (model.voteMode == RoomPKVoteModeType_NumberPerson){
|
||||
pkType = @"送礼人数多的团队获胜";
|
||||
}
|
||||
NSString * title = [NSString stringWithFormat:@"管理员创建房间PK,本次PK时间为%.0f秒,%@", model.duration, pkType];
|
||||
[attribute appendAttributedString:[self createTextAttribute:title color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
}else if (attachment.second == Custom_Message_Sub_Room_PK_Start){
|
||||
NSString * title = [NSString stringWithFormat:@"PK开始了,本次PK时间为%.0f秒,快给喜欢的选手投票吧", model.duration];
|
||||
[attribute appendAttributedString:[self createTextAttribute:title color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
}else if (attachment.second == Custom_Message_Sub_Room_PK_Re_Start){
|
||||
NSString * pkType;
|
||||
if (model.voteMode == RoomPKVoteModeType_GiftValue) {
|
||||
pkType = @"获得礼物多的团队获胜";
|
||||
}else if (model.voteMode == RoomPKVoteModeType_NumberPerson){
|
||||
pkType = @"送礼人数多的团队获胜";
|
||||
}
|
||||
NSString * title = [NSString stringWithFormat:@"管理员重新开始PK,本次PK时间为%.0f秒,%@", model.duration, pkType];
|
||||
[attribute appendAttributedString:[self createTextAttribute:title color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
}
|
||||
}
|
||||
return attribute;
|
||||
}
|
||||
|
||||
#pragma mark - 表情显示
|
||||
- (NSAttributedString*)createRoomFaceAttribute:(AttachmentModel *)attachment {
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
|
Reference in New Issue
Block a user