SocialityModel = SocialityModel or BaseClass(BaseModel)
|
|
|
|
SocialityModel.REFRESH_RED_POINT = "REFRESH_RED_POINT"
|
|
SocialityModel.REQUEST_CCMD_EVENT = "SocialityModel.REQUEST_CCMD_EVENT" --请求协议
|
|
SocialityModel.UPDATE_ADD_FRIEND_VIEW = "SocialityModel.UPDATE_ADD_FRIEND_VIEW" --更新推荐好友或搜索好友
|
|
SocialityModel.UPDATE_APPLY_FRIEND_VIEW = "SocialityModel.UPDATE_APPLY_FRIEND_VIEW" --更新好友申请列表
|
|
SocialityModel.REQUEST_SOCIAL_LIST = "SocialityModel.REQUEST_SOCIAL_LIST" --请求社交关系列表
|
|
SocialityModel.UPDATE_SOCIALITY_VIEW = "SocialityModel.UPDATE_SOCIALITY_VIEW" --更新社交列表
|
|
SocialityModel.SELECT_FIREND = "SocialityModel.SELECT_FIREND" --选中好友
|
|
SocialityModel.UPDATE_RECEIVE_VIEW = "SocialityModel.UPDATE_RECEIVE_VIEW" --更新收到鲜花界面
|
|
SocialityModel.SHOW_FLOWER_EFFECT = "SocialityModel.SHOW_FLOWER_EFFECT" --播放特效
|
|
SocialityModel.STOP_FLOWER_EFFECT = "SocialityModel.STOP_FLOWER_EFFECT" --停止播放特效
|
|
SocialityModel.UPDATE_CHARM_VIEW = "SocialityModel.UPDATE_CHARM_VIEW" --更新魅力值
|
|
SocialityModel.REQUEST_OTHER_INFO = "SocialityModel.REQUEST_OTHER_INFO" --请求他人信息,弹框
|
|
SocialityModel.UPDATE_OTHER_ROLE_RELA = "SocialityModel.UPDATE_OTHER_ROLE_RELA" --更新他人信息
|
|
|
|
SocialityModel.UPDATE_ALL_ADD_FRIEND_VIEW = "SocialityModel.UPDATE_ALL_ADD_FRIEND_VIEW" --在添加好友界面中点"一键添加好友"后刷新界面
|
|
SocialityModel.UPDATE_SMASH_EGG_MAIN_VIEW = "SocialityModel.UPDATE_SMASH_EGG_MAIN_VIEW" --在砸蛋完之后的更新界面
|
|
SocialityModel.UPDATE_EGG_VIEW_CAHRM = "SocialityModel.UPDATE_EGG_VIEW_CAHRM" --更新砸蛋界面中的对方的魅力值
|
|
SocialityModel.UPDATE_SMASH_EGG_NUM = "SocialityModel.UPDATE_SMASH_EGG_NUM" --更新砸蛋界面中的砸蛋次数
|
|
|
|
SocialityModel.OPEN_FRIEND_MSG_VIEW = "SocialityModel.OPEN_FRIEND_MSG_VIEW" --打开聊天界面上方的好友信息栏
|
|
SocialityModel.REFRESH_SUB_BTN_RED = "SocialityModel.REFRESH_SUB_BTN_RED" --刷新subBtn的红点
|
|
SocialityModel.UPDATE_TICKETS_STATE = "SocialityModel.UPDATE_TICKETS_STATE" --刷新票券状态
|
|
SocialityModel.UPDATE_FLOWER_NUM = "SocialityModel.UPDATE_FLOWER_NUM" --送礼后刷新送礼界面
|
|
SocialityModel.ANS_FRIEND_SHOW_DATA = "SocialityModel.ANS_FRIEND_SHOW_DATA" --查询好友信息返回形象
|
|
|
|
SocialityModel.UPDATE_ALL_TICKETS_STATE = "SocialityModel.UPDATE_ALL_TICKETS_STATE"
|
|
|
|
SocialityModel.CLOSE_ASSISTANT_CONTENT_BAR = "SocialityModel.CLOSE_ASSISTANT_BAR" --关闭小助手的上拉栏
|
|
SocialityModel.UPDATE_RECOMMEND_TEXT = "SocialityModel.UPDATE_RECOMMEND_TEXT" --刷新推荐好友文本为查找结果
|
|
SocialityModel.CHAT_WITH_ROLEID = "SocialityModel.CHAT_WITH_ROLEID"--和指定id的人聊天
|
|
SocialityModel.UPDATE_SOCIALITY_RECENT_VIEW = "SocialityModel.UPDATE_SOCIALITY_RECENT_VIEW"--刷新最近联系人界面
|
|
|
|
SocialityModel.UPDATE_ONE_WAY_SCROLL_VIEW_SIZE = "SocialityModel.UPDATE_ONE_WAY_SCROLL_VIEW_SIZE" -- 刷新聊天框大小
|
|
SocialityModel.UPDATE_TAB_SUB_ITEM = "SocialityModel.UPDATE_TAB_SUB_ITEM"
|
|
SocialityModel.BROADCAST_MIDDLE_MESSAGE = "SocialityModel.BROADCAST_MIDDLE_MESSAGE" -- 广播指定系统提示
|
|
|
|
SocialityModel.UPDATE_ADD_FRIEND_BTN_STATE = "SocialityModel.UPDATE_ADD_FRIEND_BTN_STATE" --添加好友后更新添加按钮的状态
|
|
|
|
SocialityModel.OPEN_SOCIALITY_INTIMACY_ADDITION_AFTER_FIGURE = "SocialityModel.OPEN_SOCIALITY_INTIMACY_ADDITION_AFTER_FIGURE"
|
|
|
|
SocialityModel.REFRESH_SOCIALITY_SP_GIFT_LIMIT = "SocialityModel.REFRESH_SOCIALITY_SP_GIFT_LIMIT"
|
|
SocialityModel.UPDATE_RECEIVE_RECORD_THANK_STATE = "SocialityModel.UPDATE_RECEIVE_RECORD_THANK_STATE"--刷新收礼记录感谢状态
|
|
|
|
SocialityModel.Index2Name =
|
|
{
|
|
[1] = {id = 1, name = "好友",module_id = 140, sub_id = 0},
|
|
[2] = {id = 2, name = "添加",module_id = 140, sub_id = 0},
|
|
[3] = {id = 3, name = "邮件",module_id = 190, sub_id = 0},
|
|
}
|
|
|
|
SocialityModel.TicketType =
|
|
{
|
|
Friend = 1,--好友互送名望券
|
|
Mate = 2,--羁绊点
|
|
}
|
|
|
|
function SocialityModel:__init()
|
|
SocialityModel.Instance = self
|
|
self:Reset()
|
|
end
|
|
|
|
function SocialityModel:Reset( )
|
|
self.relative_info = {} --关系列表
|
|
self.apply_info = {} --好友申请列表
|
|
self.receive_info = {} --收到鲜花信息
|
|
self.flower_effect_list = {}
|
|
self.charm_info = {} --魅力值,名誉,鲜花数信息
|
|
self.sociality_is_open = false --社交界面是否打开
|
|
self.has_private_chat = false --社交 是否有人私聊
|
|
|
|
self.last_give_flower_info = nil --上次送礼的一个玩家记录
|
|
self.search_info = {} --通过搜索得到的玩家信息
|
|
self.is_open_give_view = false --是否打开送花界面
|
|
self.has_new_flower_record = false --是否有新的送花记录
|
|
|
|
self.not_update_recent = false
|
|
|
|
self.last_inform_id = nil --本次登录中上次举报的人
|
|
|
|
self.temp_chat_msg_content = nil --私聊好友的临时文本
|
|
|
|
self.friend_tab_index = 2 --联系人列表的页签 1:最近 2:好友
|
|
|
|
self.egg_info = nil --砸蛋次数等信息
|
|
|
|
self.red_dot_list = {}
|
|
|
|
self.thank_list = {}
|
|
|
|
self.friend_state_list = {} --存放好友对自己的状态的列表,状态1:自己在对方好友列表中,状态6:自己不在对方好友列表中
|
|
|
|
self.sp_gift_limit_data = {}
|
|
|
|
self:ResetTickInfo()
|
|
end
|
|
|
|
--设置存放好友对自己的状态的列表,状态1:自己在对方好友列表中,状态6:自己不在对方好友列表中
|
|
function SocialityModel:SetFriendStateList(vo)
|
|
for k,v in pairs(vo.opp_rela_list) do
|
|
self.friend_state_list[v.role_id] = {}
|
|
self.friend_state_list[v.role_id].role_id = v.role_id
|
|
self.friend_state_list[v.role_id].opp_rela_type = v.opp_rela_type
|
|
self.friend_state_list[v.role_id].ask_response_status = v.ask_response_status
|
|
end
|
|
end
|
|
|
|
--判断自己是否是对方的单向好友
|
|
function SocialityModel:IsOneWayToFriend(role_id)
|
|
if self.friend_state_list[role_id] and self.friend_state_list[role_id].opp_rela_type == 6 then
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
--获取好友处理自己好友请求的处理状态 0-未响应 1-已拒绝 (主要用于单向好友的处理)
|
|
function SocialityModel:GetAskResponseStatus(role_id)
|
|
if self.friend_state_list[role_id] then
|
|
return self.friend_state_list[role_id].ask_response_status
|
|
end
|
|
return 0
|
|
end
|
|
|
|
|
|
function SocialityModel:ResetTickInfo( )
|
|
self.tickets_send_count = 0 --票券每日赠送次数
|
|
self.tickets_gift_count = 0 --票券每日收礼次数
|
|
self.send_role_list = {
|
|
[SocialityModel.TicketType.Friend] = {},
|
|
[SocialityModel.TicketType.Mate] = {}
|
|
} --票券已赠玩家列表
|
|
self.gift_role_list = {
|
|
[SocialityModel.TicketType.Friend] = {},
|
|
[SocialityModel.TicketType.Mate] = {}
|
|
} --票券收礼玩家列表
|
|
end
|
|
|
|
function SocialityModel:getInstance()
|
|
if SocialityModel.Instance == nil then
|
|
SocialityModel.New()
|
|
end
|
|
return SocialityModel.Instance
|
|
end
|
|
|
|
function SocialityModel:GetSocialSubView( index )
|
|
local sub_view = nil
|
|
if index == 1 then
|
|
sub_view = SocialityFriendView
|
|
elseif index == 3 then
|
|
sub_view = SocialityMailView
|
|
elseif index == 2 then
|
|
sub_view = SocialityAddFriendView
|
|
end
|
|
return sub_view
|
|
end
|
|
|
|
function SocialityModel:GetTabData( )
|
|
local tab_data = {}
|
|
for i,v in ipairs(SocialityModel.Index2Name) do
|
|
table.insert(tab_data, SocialityModel.Index2Name[i])
|
|
end
|
|
-- local tab_data = {"好友","邮件",}
|
|
-- if ClientConfig.alpha_mode then --审核状态屏蔽邮件 --暂时不需要屏蔽
|
|
-- tab_data = {{name = "好友", light_res = "", dark_res = ""}}
|
|
-- end
|
|
return tab_data
|
|
end
|
|
|
|
-- 判断是否到达好友数量上限
|
|
function SocialityModel:CheckIsFullFriend()
|
|
local is_full = false
|
|
local cfg = Config.Relaconfig
|
|
if cfg and cfg[1] then
|
|
local list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
if list then
|
|
is_full = TableSize(list) == cfg[1].value
|
|
end
|
|
end
|
|
return is_full
|
|
end
|
|
|
|
function SocialityModel:GetFriendTabData( )
|
|
local tab_data = {
|
|
-- [1] = {main_tab = "最近联系", sub_tab = {}, info = {}},
|
|
-- [2] = {main_tab = "我的好友", sub_tab = {}, info = {}},
|
|
-- [3] = {main_tab = "社团成员", sub_tab = {}, info = {}},
|
|
-- [4] = {main_tab = "我的仇人", sub_tab = {}, info = {}},
|
|
-- [5] = {main_tab = "黑名单", sub_tab = {}, info = {}},
|
|
|
|
[1] = {main_tab = "我的好友", sub_tab = {}, info = {}},
|
|
[2] = {main_tab = "羁绊", sub_tab = {}, info = {}},
|
|
[3] = {main_tab = "黑名单", sub_tab = {}, info = {}},
|
|
}
|
|
|
|
local function setInfo( index, type )
|
|
local list = self:GetRelativeInfoByType(type)
|
|
tab_data[index].sub_tab = list
|
|
local info = tab_data[index].info
|
|
info.totalNum = #list
|
|
info.onLineNum = self:GetOnLineNumByType(type)
|
|
end
|
|
-- --最近联系
|
|
-- local list, num = self:GetRecentFriendList()
|
|
-- tab_data[1].sub_tab = list
|
|
-- local info = tab_data[1].info
|
|
-- info.totalNum = #list
|
|
-- info.onLineNum = num
|
|
--好友
|
|
setInfo(1, Config.ConfigSocial.RelativeType.friend)
|
|
--羁绊
|
|
setInfo(2, Config.ConfigSocial.RelativeType.magee)
|
|
--黑名单
|
|
setInfo(3, Config.ConfigSocial.RelativeType.black)
|
|
return tab_data
|
|
end
|
|
|
|
function SocialityModel:GetRecentFriendTabData()
|
|
local tab_data = {
|
|
[1] = {main_tab = "最近联系", sub_tab = {}, info = {}},
|
|
}
|
|
|
|
--最近联系
|
|
local list, num = self:GetRecentFriendList()
|
|
tab_data[1].sub_tab = list
|
|
local info = tab_data[1].info
|
|
info.totalNum = #list
|
|
info.onLineNum = num
|
|
|
|
return tab_data
|
|
end
|
|
|
|
function SocialityModel:GetInfoByIndex( index, sub_index )
|
|
local list = {}
|
|
--如果传进来的index是1要分两种情况,当前栏是最近联系人和当前栏是联系人
|
|
if index == 1 then
|
|
if self.friend_tab_index == 1 then
|
|
list = self:GetRecentFriendList()
|
|
else
|
|
list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
end
|
|
elseif index == 2 then
|
|
list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.magee)
|
|
elseif index == 3 then
|
|
list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.black)
|
|
-- elseif index == 5 then
|
|
-- list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.black)
|
|
end
|
|
return list[sub_index]
|
|
end
|
|
|
|
--根据私聊id查找索引
|
|
function SocialityModel:GetIndexByChatKey( key )
|
|
local list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
for k,v in pairs(list) do
|
|
if v.role_id == key then
|
|
return 1, k
|
|
end
|
|
end
|
|
list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.magee)
|
|
for k,v in pairs(list) do
|
|
if v.role_id == key then
|
|
return 2, k
|
|
end
|
|
end
|
|
list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.black)
|
|
for k,v in pairs(list) do
|
|
if v.role_id == key then
|
|
return 3, k
|
|
end
|
|
end
|
|
end
|
|
|
|
function SocialityModel:GetRecentListIndex(key)
|
|
local list = self:GetRecentFriendList()
|
|
for k,v in pairs(list) do
|
|
if v.role_id == key then
|
|
return 1, k
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
function SocialityModel:InitRelaList( )
|
|
self.relative_info[1] = {}
|
|
self.relative_info[2] = {}
|
|
self.relative_info[5] = {}
|
|
self.relative_info[6] = {}
|
|
end
|
|
|
|
function SocialityModel:SetRelativeInfo(type,list,do_not_sort)
|
|
self.relative_info[type] = {}
|
|
--排序 online_flag为2是离线挂机,当成0来排序
|
|
for k,v in pairs(list) do
|
|
if v.online_flag==2 then
|
|
v.isOnline = 0
|
|
else
|
|
v.isOnline = v.online_flag
|
|
end
|
|
-- if type == Config.ConfigSocial.RelativeType.black then
|
|
-- v.intimacy = 0
|
|
-- end
|
|
end
|
|
if not do_not_sort then
|
|
if type == Config.ConfigSocial.RelativeType.friend then
|
|
local arg = {"isOnline", "intimacy", "lv", "add_time"}
|
|
local condition = {Array.UPPER, Array.UPPER, Array.UPPER, Array.LOWER,}
|
|
SortTools.MoreKeysSorter(list, arg, condition)
|
|
elseif type == Config.ConfigSocial.RelativeType.magee then
|
|
local arg = {"isOnline", "intimacy", "lv", "add_time"}
|
|
local condition = {Array.UPPER, Array.UPPER, Array.UPPER, Array.LOWER,}
|
|
SortTools.MoreKeysSorter(list, arg, condition)
|
|
-- elseif type == Config.ConfigSocial.RelativeType.enemy then
|
|
-- local arg = {"isOnline", "add_time"}
|
|
-- local condition = {Array.UPPER, Array.LOWER,}
|
|
-- SortTools.MoreKeysSorter(list, arg, condition)
|
|
-- elseif type == Config.ConfigSocial.RelativeType.black then
|
|
-- local arg = {"add_time"}
|
|
-- local condition = {Array.LOWER,}
|
|
-- SortTools.MoreKeysSorter(list, arg, condition)
|
|
end
|
|
end
|
|
--如果是type=5最近联系人的时候,在GetRecentFriendList中单独进行排序
|
|
--如果type=6单向好友时,不做处理,存起来就行,单向好友不做单独列表展示,只用于最近联系人里查询
|
|
|
|
|
|
if type == 1 then
|
|
--添加“小助手”联系人
|
|
local assistant = {}
|
|
assistant.lv = 0
|
|
assistant.guild_name = ""
|
|
assistant.marriage_type = 0
|
|
assistant.last_logout_time = 0
|
|
assistant.sup_vip_type = 0
|
|
assistant.profile_photo_id = 999999
|
|
assistant.add_time = 0
|
|
assistant.vip_flag = 0
|
|
assistant.isOnline = 1
|
|
assistant.sex = 2
|
|
assistant.role_id = 1
|
|
assistant.role_name = "AI管家"
|
|
assistant.career = 0
|
|
assistant.intimacy = 0
|
|
assistant.online_flag = 1
|
|
assistant.turn = 0
|
|
assistant.last_chat_time = 0
|
|
|
|
local is_have = false
|
|
for k,v in pairs(list) do
|
|
if v.role_id == 1 then
|
|
is_have = true
|
|
end
|
|
end
|
|
if not is_have then
|
|
table.insert(list,1,assistant)
|
|
end
|
|
end
|
|
|
|
self.relative_info[type] = list
|
|
end
|
|
|
|
function SocialityModel:GetRelativeInfoByType( type )
|
|
return self.relative_info[type] or {}
|
|
end
|
|
|
|
function SocialityModel:UpdateShieldList( action_type,data)
|
|
-- local list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.black)
|
|
self.relative_info[Config.ConfigSocial.RelativeType.black] = self.relative_info[Config.ConfigSocial.RelativeType.black] or {}
|
|
if not data then return end
|
|
data.isOnline = 0
|
|
-- data.intimacy = 0
|
|
if action_type == 1 then
|
|
--先对figuredata进行一次参数的转化,使其和好友的info信息匹配
|
|
local new_data = self:TranslateFigureData(data)
|
|
table.insert(self.relative_info[Config.ConfigSocial.RelativeType.black],new_data)
|
|
else
|
|
for k,v in pairs(self.relative_info[Config.ConfigSocial.RelativeType.black]) do
|
|
if v.role_id == data.role_id then
|
|
-- self.relative_info[Config.ConfigSocial.RelativeType.black][k] = nil
|
|
table.remove(self.relative_info[Config.ConfigSocial.RelativeType.black],k)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--收到私聊消息后更新和该好友的最后私聊时间
|
|
function SocialityModel:UpdateLastChatTime(role_id, last_chat_time)
|
|
if self.relative_info and self.relative_info[Config.ConfigSocial.RelativeType.friend] then
|
|
for k,v in pairs(self.relative_info[Config.ConfigSocial.RelativeType.friend]) do
|
|
if v.role_id == role_id then
|
|
v.last_chat_time = last_chat_time
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--获取好友的信息
|
|
function SocialityModel:GetFriendData(role_id)
|
|
if self.relative_info then
|
|
for k,v in pairs(self.relative_info) do
|
|
for kk,vv in pairs(v) do
|
|
if vv.role_id == role_id then
|
|
return vv
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
--有可能会遗漏,屏蔽名单数据再出现问题的话来这里和figureProtocol对照一下
|
|
function SocialityModel:TranslateFigureData( data )
|
|
local new_data = {}
|
|
new_data.role_id = data.role_id
|
|
new_data.role_name = data.name
|
|
new_data.career = data.career
|
|
new_data.sex = data.sex
|
|
new_data.turn = data.turn
|
|
new_data.lv = data.level
|
|
new_data.sup_vip_type = data.sup_vip_type
|
|
new_data.vip = data.vip_flag
|
|
new_data.picture = data.picture
|
|
new_data.picture_ver = data.picture_ver
|
|
new_data.online_flag = 0
|
|
new_data.intimacy = 0
|
|
new_data.marriage_type = data.is_marriage
|
|
new_data.last_chat_time = 0
|
|
new_data.add_time = 0
|
|
new_data.guild_name = data.guild_name
|
|
new_data.last_logout_time = 0
|
|
new_data.profile_photo_id = data.profile_photo_id
|
|
return new_data
|
|
end
|
|
|
|
function SocialityModel:SetApplyInfo( info )
|
|
self.apply_info = info
|
|
end
|
|
|
|
function SocialityModel:GetApplyInfo( )
|
|
return self.apply_info
|
|
end
|
|
|
|
--获取请求好友的红点数量
|
|
function SocialityModel:GetApplyInfoRedNum( )
|
|
if self.apply_info and self.apply_info.ask_list then
|
|
return #self.apply_info.ask_list
|
|
else
|
|
return 0
|
|
end
|
|
end
|
|
|
|
function SocialityModel:SetReceiveInfo( info )
|
|
self.receive_info = info
|
|
self:GetRecentGiveFlowerInfo() --筛选出最近送花的一个
|
|
end
|
|
|
|
function SocialityModel:GetReceiveInfo(type)
|
|
local data = {}
|
|
if type == 1 or type == 2 then
|
|
for i,v in ipairs(self.receive_info.record_list) do
|
|
if v.code == type then
|
|
table.insert(data,v)
|
|
end
|
|
end
|
|
end
|
|
return #data ~= 0 and data or nil
|
|
end
|
|
|
|
--22309
|
|
function SocialityModel:UpdateGiftReciveThankState(vo)
|
|
for i,v in ipairs(self.receive_info.record_list) do
|
|
if v.code == 2 and v.id == vo.id then
|
|
v.thank = 1
|
|
end
|
|
end
|
|
end
|
|
|
|
function SocialityModel:SetCharmInfo( info )
|
|
self.charm_info = info
|
|
end
|
|
|
|
function SocialityModel:GetCharmInfo( )
|
|
return self.charm_info
|
|
end
|
|
|
|
function SocialityModel:SetSearchInfo( vo )
|
|
self.search_info =
|
|
{role_id = vo.role_id, role_name = vo.role_name, career = vo.career, sex = vo.sex,
|
|
turn = vo.turn, lv = vo.lv, vip = vo.vip,picture = vo.picture,
|
|
picture_ver = vo.picture_ver, online_flag = vo.online_flag,sup_vip_type = vo.sup_vip_type}
|
|
|
|
end
|
|
|
|
--获取某类型好友的在线人数
|
|
function SocialityModel:GetOnLineNumByType( type )
|
|
local count = 0
|
|
local list = self:GetRelativeInfoByType(type)
|
|
for k,v in pairs(list) do
|
|
if v.online_flag == 1 then
|
|
count = count + 1
|
|
end
|
|
end
|
|
return count
|
|
end
|
|
|
|
--获取最近联系的10个好友 与在线人数
|
|
function SocialityModel:GetRecentFriendList( )
|
|
local tb = {}
|
|
local count = 0
|
|
|
|
-- local list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
local tb = DeepCopy(self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.recent))
|
|
-- for k,v in pairs(list) do
|
|
-- -- if v.last_chat_time~=0 then
|
|
-- table.insert(tb, v)
|
|
-- -- end
|
|
-- end
|
|
local arg = {"last_chat_time","last_logout_time"}
|
|
local condition = {Array.UPPER,Array.UPPER}
|
|
SortTools.MoreKeysSorter(tb, arg, condition)
|
|
|
|
local result = {}
|
|
local len = #tb>10 and 10 or #tb
|
|
for i=1, len do
|
|
if tb[i].online_flag==1 then
|
|
count = count + 1
|
|
end
|
|
table.insert(result, tb[i])
|
|
end
|
|
--在最近联系人一栏中添加“小助手”联系人
|
|
local assistant = {}
|
|
assistant.lv = 0
|
|
assistant.guild_name = ""
|
|
assistant.marriage_type = 0
|
|
assistant.last_logout_time = 0
|
|
assistant.sup_vip_type = 0
|
|
assistant.profile_photo_id = 999999
|
|
assistant.add_time = 0
|
|
assistant.vip_flag = 0
|
|
assistant.isOnline = 1
|
|
assistant.sex = 2
|
|
assistant.role_id = 1
|
|
assistant.role_name = "AI管家"
|
|
assistant.career = 0
|
|
assistant.intimacy = 0
|
|
assistant.online_flag = 1
|
|
assistant.turn = 0
|
|
assistant.last_chat_time = 0
|
|
|
|
table.insert(result,1,assistant)
|
|
|
|
|
|
return result, count
|
|
end
|
|
|
|
--是否好友, 仇人, 黑名单
|
|
function SocialityModel:IsRelaviveType( id, type )
|
|
local list = self:GetRelativeInfoByType(type)
|
|
for k,v in ipairs(list) do
|
|
if v.role_id == id then
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
|
|
--获得和该玩家的亲密度
|
|
function SocialityModel:GetIntimacyByRoleID(role_id,relavive_type)
|
|
local temp_list = self:GetRelativeInfoByType(relavive_type)
|
|
for i,v in ipairs(temp_list) do
|
|
if v.role_id == role_id then
|
|
return v.intimacy
|
|
end
|
|
end
|
|
return 0
|
|
end
|
|
|
|
--根据亲密度获取花语等级
|
|
function SocialityModel:GetLvByIntimacy( intimacy )
|
|
local lv = #Config.Intimacylv
|
|
for k,v in ipairs(Config.Intimacylv) do
|
|
if v.intimacy > intimacy then
|
|
lv = tonumber(v.lv) - 1
|
|
break
|
|
end
|
|
end
|
|
return lv
|
|
end
|
|
|
|
--获取最大亲密度等级
|
|
function SocialityModel:GetMaxIntimacyLv( )
|
|
return #Config.Intimacylv
|
|
end
|
|
|
|
function SocialityModel:GetMaxIntimacyByLv( lv )
|
|
intimacy = 999999999
|
|
for k,v in pairs(Config.Intimacylv) do
|
|
if v.lv == lv+1 then
|
|
intimacy = v.intimacy
|
|
break
|
|
end
|
|
end
|
|
return intimacy
|
|
end
|
|
|
|
--获取指定亲密等级的初始亲密度
|
|
function SocialityModel:GetIntimacyByLv(lv)
|
|
for k,v in pairs(Config.Intimacylv) do
|
|
if v.lv == lv then
|
|
return v.intimacy
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
function SocialityModel:GetIntimacyAttrByLv( lv )
|
|
local data = {}
|
|
if lv then
|
|
for k,v in pairs(Config.Intimacylv) do
|
|
if v.lv == lv then
|
|
data = stringtotable(v.attr)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
return data
|
|
end
|
|
|
|
--根据亲密度等级获取颜色
|
|
function SocialityModel:GetColorByIntimacyLv( lv )
|
|
local color_id = 0
|
|
for k,v in pairs(Config.Intimacylv) do
|
|
if v.lv == lv then
|
|
color_id = v.color
|
|
break
|
|
end
|
|
end
|
|
return ColorUtil:GetGoodsColor(color_id),color_id
|
|
end
|
|
|
|
--播放送花特效
|
|
function SocialityModel:PlayFlowerEffect(vo)
|
|
if #self.flower_effect_list >= 20 then
|
|
table.remove(self.flower_effect_list,1)
|
|
table.insert(self.flower_effect_list,vo)
|
|
else
|
|
table.insert(self.flower_effect_list,vo)
|
|
end
|
|
self:Fire(SocialityModel.SHOW_FLOWER_EFFECT)
|
|
end
|
|
|
|
--获取当前名誉名字
|
|
function SocialityModel:GetFameName( )
|
|
local info = self:GetCharmInfo()
|
|
local name = ""
|
|
if info and info.fame then
|
|
|
|
for i,v in ipairs(Config.Famelv) do
|
|
if info.fame>=v.fame then
|
|
name = v.name
|
|
else
|
|
break
|
|
end
|
|
end
|
|
end
|
|
return name
|
|
end
|
|
|
|
--获取当前名誉级别
|
|
function SocialityModel:GetFameIndex( )
|
|
local info = self:GetCharmInfo()
|
|
local index = 1
|
|
if info and info.fame then
|
|
for i,v in ipairs(Config.Famelv) do
|
|
if info.fame>=v.fame then
|
|
index = v.lv
|
|
else
|
|
break
|
|
end
|
|
end
|
|
end
|
|
return index
|
|
end
|
|
|
|
|
|
function SocialityModel:GetFriendOnLine()
|
|
local list = {}
|
|
local friendList = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
for i,v in ipairs(friendList) do
|
|
if v.online_flag == 1 then
|
|
table.insert(list,v)
|
|
end
|
|
end
|
|
return list
|
|
end
|
|
|
|
function SocialityModel:GetVoById(type, role_id)
|
|
local list = self:GetRelativeInfoByType(type)
|
|
for i,v in ipairs(list) do
|
|
if v.role_id == role_id then
|
|
return v
|
|
end
|
|
end
|
|
end
|
|
|
|
function SocialityModel:GetVoByOnlyId(role_id)
|
|
local list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
for i,v in ipairs(list) do
|
|
if v.role_id == role_id then
|
|
return v
|
|
end
|
|
end
|
|
list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.magee)
|
|
for i,v in ipairs(list) do
|
|
if v.role_id == role_id then
|
|
return v
|
|
end
|
|
end
|
|
-- list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.enemy)
|
|
-- for i,v in ipairs(list) do
|
|
-- if v.role_id == role_id then
|
|
-- return v
|
|
-- end
|
|
-- end
|
|
list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.black)
|
|
for i,v in ipairs(list) do
|
|
if v.role_id == role_id then
|
|
return v
|
|
end
|
|
end
|
|
end
|
|
|
|
function SocialityModel:GetGiveList(new_list)
|
|
local is_true = false
|
|
local list = {}
|
|
local friend_list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
for i,v in pairs(new_list) do
|
|
if v ~= nil then
|
|
is_true = true
|
|
break
|
|
end
|
|
end
|
|
if not is_true then --new_list or #new_list <= 0 --判断table内有没有数据不能用# 可以用TableSize
|
|
list = friend_list
|
|
else
|
|
table.insert(list, new_list)
|
|
for i,v in ipairs(friend_list) do
|
|
-- if v.role_id == new_list.role_id then
|
|
-- table.remove(friend_list, i)
|
|
-- end
|
|
if v.role_id ~= new_list.role_id then --这里因为table的引用机制,所以不能用table.remove,会将关系列表中的好友删除
|
|
table.insert(list, v)
|
|
end
|
|
end
|
|
end
|
|
-- table.insert(list, new_list)
|
|
-- for i,v in ipairs(friend_list) do
|
|
-- table.insert(list, v)
|
|
-- end
|
|
|
|
return list
|
|
end
|
|
|
|
function SocialityModel:GetRecentGiveFlowerInfo()
|
|
if not self.receive_info.record_list or #self.receive_info.record_list < 0 then return end
|
|
|
|
local has_record = false --先判断有没有送花记录先
|
|
for i,v in pairs(self.receive_info.record_list) do
|
|
if v and v.code == 1 then
|
|
has_record = true
|
|
break
|
|
end
|
|
end
|
|
if has_record == false then return end
|
|
local min_time_list = self.receive_info.record_list[1]
|
|
for i,v in pairs(self.receive_info.record_list) do
|
|
if (v.time >= min_time_list.time and v.code == 1) then
|
|
min_time_list = v
|
|
end
|
|
end
|
|
self.last_give_flower_info = min_time_list
|
|
end
|
|
|
|
function SocialityModel:GetSearchInfo()
|
|
return self.search_info
|
|
end
|
|
|
|
function SocialityModel:SetLastGive(list)
|
|
self.last_give_flower_info = list
|
|
end
|
|
|
|
function SocialityModel:GetLastInfo()
|
|
return self.last_give_flower_info
|
|
end
|
|
|
|
--设置票券数据
|
|
function SocialityModel:SetTicketsData(vo)
|
|
self:ResetTickInfo()
|
|
-------------------------
|
|
self.tickets_send_count = vo.send_count
|
|
self.tickets_gift_count = vo.gift_count
|
|
for k,v in pairs(vo.send_info) do
|
|
table.insert(self.send_role_list[v.type],v)
|
|
end
|
|
for k,v in pairs(vo.gift_info) do
|
|
table.insert(self.gift_role_list[v.type],v)
|
|
end
|
|
self:Fire(SocialityModel.UPDATE_ALL_TICKETS_STATE)
|
|
end
|
|
|
|
--获取还没赠送票券的好友id列表
|
|
function SocialityModel:GetCanSendTicketFriendIdList( )
|
|
local need_id_list = {}
|
|
local friend_list = DeepCopy(self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend))
|
|
|
|
local arg = {"isOnline", "intimacy", "lv", "add_time"}
|
|
local condition = {Array.UPPER, Array.UPPER, Array.UPPER, Array.LOWER,}
|
|
SortTools.MoreKeysSorter(friend_list, arg, condition)
|
|
|
|
local left_send_times = Config.Relaconfig[2].value-self.tickets_send_count
|
|
|
|
local special_flag = left_send_times <= 0
|
|
|
|
for i,v in ipairs(friend_list) do
|
|
if v.role_id~=1 and not self:IsOneWayToFriend(v.role_id) and not self:IsInSendRoleList(v.role_id,SocialityModel.TicketType.Friend) and #need_id_list<left_send_times then
|
|
table.insert(need_id_list,v.role_id)
|
|
end
|
|
end
|
|
return need_id_list,special_flag
|
|
end
|
|
|
|
--获取还没领票券的好友id列表
|
|
function SocialityModel:GetCanGetTicketFriendIdList( )
|
|
local need_id_list = {}
|
|
local friend_list = self:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.friend)
|
|
for i,v in ipairs(friend_list) do
|
|
if v.role_id~=1 and not self:IsOneWayToFriend(v.role_id) and self:IsInGiftRoleList(v.role_id,SocialityModel.TicketType.Friend) then
|
|
if self:GetTicketsGiftState(v.role_id) == 0 then
|
|
table.insert(need_id_list,v.role_id)
|
|
end
|
|
end
|
|
end
|
|
return need_id_list
|
|
end
|
|
|
|
--判断是否送了该好友票券
|
|
function SocialityModel:IsInSendRoleList(role_id,op_type)
|
|
op_type = op_type or SocialityModel.TicketType.Friend
|
|
for k,v in pairs(self.send_role_list[op_type]) do
|
|
if role_id == v.role_id0 then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
--判断该好友是否赠送了自己票券
|
|
function SocialityModel:IsInGiftRoleList(role_id,op_type)
|
|
op_type = op_type or SocialityModel.TicketType.Friend
|
|
for k,v in pairs(self.gift_role_list[op_type]) do
|
|
if role_id == v.role_id1 then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
--收送票券后刷新票券状态
|
|
function SocialityModel:UpdateTicketsState(state_type,role_id,op_type)
|
|
op_type = op_type or SocialityModel.TicketType.Friend
|
|
if state_type == 1 then--送票券之后
|
|
local tb = {}
|
|
tb.role_id0 = role_id
|
|
table.insert(self.send_role_list[op_type],tb)
|
|
if op_type == SocialityModel.TicketType.Friend then
|
|
self.tickets_send_count = self.tickets_send_count+1 <= Config.Relaconfig[2].value and self.tickets_send_count+1 or Config.Relaconfig[2].value
|
|
end
|
|
elseif state_type == 2 then--领票券之后
|
|
for k,v in pairs(self.gift_role_list[op_type]) do
|
|
if role_id == v.role_id1 then
|
|
v.val = 1
|
|
end
|
|
end
|
|
if op_type == SocialityModel.TicketType.Friend then
|
|
self.tickets_gift_count = self.tickets_gift_count+1 <= Config.Relaconfig[3].value and self.tickets_gift_count+1 or Config.Relaconfig[3].value
|
|
end
|
|
end
|
|
end
|
|
|
|
function SocialityModel:UpdateGiftRoleList(role_id,op_type)
|
|
op_type = op_type or SocialityModel.TicketType.Friend
|
|
local tb = {}
|
|
tb.role_id1 = role_id
|
|
tb.val = 0
|
|
table.insert(self.gift_role_list[op_type],tb)
|
|
end
|
|
|
|
--获取该角色送礼给我的领取情况
|
|
function SocialityModel:GetTicketsGiftState(role_id,op_type)
|
|
op_type = op_type or SocialityModel.TicketType.Friend
|
|
for k,v in pairs(self.gift_role_list[op_type]) do
|
|
if role_id == v.role_id1 then
|
|
return v.val
|
|
end
|
|
end
|
|
end
|
|
|
|
function SocialityModel:GetThankList( )
|
|
return self.thank_list
|
|
end
|
|
|
|
function SocialityModel:SetThankList( value )
|
|
self.thank_list[value] = value
|
|
end
|
|
|
|
function SocialityModel:AssistantSendMsg(msg)
|
|
local mainVo = RoleManager.Instance.mainRoleInfo
|
|
|
|
local info_assistant = {}
|
|
info_assistant.channel = ChatModel.CHANNEL_CECRET
|
|
info_assistant.ser_id = mainVo.server_id
|
|
info_assistant.ser_num = 0
|
|
info_assistant.ser_name = LoginController.Instance:GetPlatUserInfo().server_name
|
|
info_assistant.player_list = {}
|
|
local tb2 = {}
|
|
tb2.player_id = mainVo.role_id
|
|
tb2.name = mainVo.name
|
|
tb2.level = mainVo.level
|
|
tb2.career = mainVo.career
|
|
tb2.dress_list = nil
|
|
tb2.guild_id = mainVo.guild_id
|
|
tb2.sex = mainVo.sex
|
|
tb2.vip_flag = VipModel:getInstance():GetVipLevel()
|
|
tb2.sup_vip_type = mainVo.sup_vip_type
|
|
tb2.turn = mainVo.turn
|
|
tb2.ser_id = mainVo.server_id
|
|
-- tb2.picture_ver = mainVo.picture_ver
|
|
-- tb2.picture = mainVo.picture
|
|
tb2.profile_photo_id = mainVo.profile_photo_id
|
|
-- ser_num = 0
|
|
tb2.ser_name = LoginController.Instance:GetPlatUserInfo().server_name
|
|
tb2.GM = mainVo.gm_flag
|
|
local tb1 = {}
|
|
tb1.player_id = 1
|
|
tb1.name = "AI管家"
|
|
tb1.level = 0
|
|
tb1.career = 0
|
|
tb1.dress_list = nil
|
|
tb1.guild_id = 0
|
|
tb1.sex = 2
|
|
tb1.vip_flag = 0
|
|
tb1.sup_vip_type = 0
|
|
tb1.turn = 0
|
|
tb1.ser_id = mainVo.server_id
|
|
tb1.profile_photo_id = 999999
|
|
-- ser_num = 0
|
|
tb1.ser_name = LoginController.Instance:GetPlatUserInfo().server_name
|
|
tb1.GM = 0
|
|
table.insert(info_assistant.player_list,tb1)
|
|
table.insert(info_assistant.player_list,tb2)
|
|
info_assistant.msg = msg
|
|
|
|
info_assistant.time = TimeUtil:getServerTime()
|
|
ChatModel:getInstance():AddMsg(info_assistant)
|
|
|
|
ChatModel:getInstance():Fire(ChatModel.CHANGE_CHANNEL_SEND_INTERVAL, info_assistant)
|
|
ChatModel:getInstance():Fire(ChatModel.UPDATE_SEND_TIME)
|
|
ChatModel:getInstance():AddMainRoleChatContent(info_assistant.msg, info_assistant.player_id)
|
|
|
|
local player_id = info_assistant.player_list[1].player_id --取出私聊对象的id
|
|
if player_id ~= RoleManager.Instance.mainRoleInfo.role_id then
|
|
--收到私聊消息后更新和该好友的最后私聊时间
|
|
SocialityModel:getInstance():UpdateLastChatTime(player_id,info_assistant.time)
|
|
ChatModel:getInstance():SetChatInfo(true,info_assistant)
|
|
ChatModel:getInstance():SetPriateChatInfo(info_assistant)--存储私聊对象的消息
|
|
SocialityModel:getInstance():Fire(SocialityModel.REFRESH_SUB_BTN_RED)--刷新subBtn红点
|
|
GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT)--更新外部红点
|
|
end
|
|
end
|
|
|
|
function SocialityModel:SetSpGiftLimitData(vo)
|
|
self.sp_gift_limit_data = vo.goods_list
|
|
end
|
|
|
|
function SocialityModel:GetSpGiftLimitData( )
|
|
return self.sp_gift_limit_data
|
|
end
|