-- PHP文档地址,用户名:dd 密码:ddtech -- http://120.76.238.236:8999/wiki/index.php?title=%E9%A6%96%E9%A1%B5 local Cmd = require("luaScript.Protocol.Club.ClubCmd") local ClubProtocolPhp = class("ClubProtocolPhp") local ClubDefine = require("luaScript.Protocol.Club.ClubDefine") function ClubProtocolPhp:ctor() -- 添加分发事件的组件 cc.GameObject.extend(self) self:addComponent(require("luaScript.cc.components.behavior.EventProtocol"):new()):exportMethods() -- 监听推送事件 app:addEventListener("onPhpMessage", handler(self, self.onPhpMessage)) --俱乐部列表 self.clubList = {} self.selectGameId = -1 self.selectBaoJianId = -1 self.bChangeTable = false -- CEST self.clubCestInfo = {} self.tiantiInfo = {} end function ClubProtocolPhp:getMatchIsOpen(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end local isArena = self.clubList[tonumber(clubId)].isArena return toNumber(isArena) == ClubDefine.MATCH_SWITCH.CLIENT_OPEN or toNumber(isArena) == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN end function ClubProtocolPhp:getCestIsOpen(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end local isArena = self.clubList[tonumber(clubId)].isArena return toNumber(isArena) == ClubDefine.MATCH_SWITCH.PEOPLE_CEST_OPEN end function ClubProtocolPhp:setCestFirst(clubId, bool) self.clubList[tonumber(clubId)].isFirst = bool end function ClubProtocolPhp:getCestFirst(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end return self.clubList[tonumber(clubId)].isFirst end function ClubProtocolPhp:getIsQuanMinSai(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end local isArena = self.clubList[tonumber(clubId)].isArena return toNumber(isArena) >= ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN end --判断是否是主盟 function ClubProtocolPhp:getIsMasterUnion(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end local isMasterUnion = self.clubList[tonumber(clubId)].groupext and (self.clubList[tonumber(clubId)].groupext.master_union == 2) or false return isMasterUnion end --判断是否是副盟 function ClubProtocolPhp:getIsSlaveUnion(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end local isMasterUnion = self.clubList[tonumber(clubId)].groupext and (self.clubList[tonumber(clubId)].groupext.slave_union == 2) or false return isMasterUnion end --判断是否是合盟 function ClubProtocolPhp:getIsUnion(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end if self:getIsMasterUnion(clubId) or self:getIsSlaveUnion(clubId) then return true else return false end end --判断是否有合盟开启权限 function ClubProtocolPhp:getUnionPower(clubId) if not clubId then return false end if not self.clubList[tonumber(clubId)] then return false end local groupext = self.clubList[tonumber(clubId)].groupext local master_union = groupext and (groupext.master_union or 0) or 0 local slave_union = groupext and (groupext.slave_union or 0) or 0 local isMasterUnion = master_union >= 1 local isSlaveUnion = slave_union >= 1 if isMasterUnion or isSlaveUnion then return true else return false end end function ClubProtocolPhp:setSelectGameId(selectGameId) self.selectGameId = selectGameId end function ClubProtocolPhp:getSelectGameId() return self.selectGameId end function ClubProtocolPhp:setSelectBaoJianId(selectBaoJianId) self.selectBaoJianId = selectBaoJianId end function ClubProtocolPhp:getSelectBaoJianId() return self.selectBaoJianId end --快速组局包间 function ClubProtocolPhp:setChangeTable(bChangeTable) self.bChangeTable = bChangeTable end function ClubProtocolPhp:getIsChangeTable() return self.bChangeTable end --bTopTip:true使用顶部tips function ClubProtocolPhp:showError(cmd,response,bTopTip) if response.error and response.error~="" then if app.club_php.clubID and app.club_php.clubID ~= 0 then if app.club_php:getCestIsOpen(app.club_php.clubID) then response.error = string.gsub(response.error, "玩家", "选手") end end if bTopTip then showTooltip(response.error) else showConfirmDialog(response.error,response.okCallBack,response.cancelCallBack) end else local code = response.code if code then if ClubDefine.Error[cmd] and ClubDefine.Error[cmd][code] then ClubDefine.Error[cmd][code] = string.gsub(ClubDefine.Error[cmd][code],"茶馆", "海选赛") if bTopTip then showTooltip(ClubDefine.Error[cmd][code]) else showConfirmDialog(ClubDefine.Error[cmd][code],response.okCallBack,response.cancelCallBack) end else showConfirmDialog("错误码:"..code) end else showTooltip("未知错误!") end end end --发送请求 function ClubProtocolPhp:post(action, param, callback) local phpAddress = getGlobalPhpUrl() local msg = {} msg.action = action msg.uid = app.user.loginInfo.uid msg.app = getAppId() if param then table.merge(msg,param) end httpPost(phpAddress, msg, function(status, response) app.waitDialogManager:closeWaitNetworkDialog() if status ~= "successed" then showPHPFailedResult("获取数据失败! status = " .. tostring(status)) else local jsonData = json.decode(response) if not jsonData or type(jsonData) ~= "table" then showPHPFailedResult("返回数据异常! response = " .. tostring(response)) else if callback then callback(jsonData) else error("callback is nil") end end end end) end --更新俱乐部数据 function ClubProtocolPhp:updateClub(v,bAll) local club = nil if bAll then if not self.clubListAll[tonumber(v.gid)] then self.clubListAll[tonumber(v.gid)] = {} end club = self.clubListAll[tonumber(v.gid)] else if not self.clubList[tonumber(v.gid)] then self.clubList[tonumber(v.gid)] = {} end club = self.clubList[tonumber(v.gid)] end club.clubId = tonumber(v.gid) or club.clubId club.clubName = v.gname or club.clubName club.ownerId = v.owner and tonumber(v.owner) or club.ownerId club.playerNum = v.gnum and tonumber(v.gnum) or club.playerNum if v.ismanage then club.isManager = tonumber(v.ismanage)==1 --当前玩家请求茶馆列表是否管理员:1是,0否 end club.role =v.role and tonumber(v.role) or club.role --1:成员 2:管理员 3:创始人 club.ownerName = v.ownernick or club.ownerName --管理员昵称 club.ownerSex = v.sex or club.ownerSex --管理员性别 club.strOwnerHeadUrl = v.ownerhead or club.strOwnerHeadUrl --管理员头像地址 club.mode = v.room_mode and tonumber(v.room_mode) or club.mode --房间模式修改1多玩法模式0包间模式 if v.hints then club.isHints = tonumber(v.hints)==1 --1:有消息红点 0:无消息红点 end if v.unionhints then club.isUnionHints = tonumber(v.unionhints)==1 --1:有消息红点 0:无消息红点 end club.stickyTime = v.sticky_time or club.stickyTime --置顶时间 club.onlineRoomNum = v.onlineroom and tonumber(v.onlineroom) or club.onlineRoomNum or 0 --在线桌数 if v.is_apply then club.isApply = tonumber(v.is_apply) == 1 --加入茶馆是否需要审核。1需要申请,0无需申请 end if v.is_exitapply then club.isExitApply = tonumber(v.is_exitapply) == 1 --退出茶馆是否需要审核。1需要申请,0无需申请 end club.status = v.status and tonumber(v.status) or club.status --1正常2冻结 club.onlinePlayerNum = v.onlinemember and tonumber(v.onlinemember) or club.onlinePlayerNum --在线人数 club.playWinScore = v.play_win_threshold and tonumber(v.play_win_threshold) or club.playWinScore or 0 --俱乐部公告 club.notice = v.notice or "" club.noticeInfo = v.noticeInfo or {} club.rooms = club.rooms or {} --初始房间列表 club.posList = club.posList or {} --初始房间pos列表 club.baoJians = club.baoJians or {} --初始包间列表 club.config = v.config or club.config or {} club.ext = v.ext or club.ext or {} club.players = club.players or {} --初始成员列表 club.playersLevelOne = club.playersLevelOne or {} --初始一级(队长)合伙人成员列表 club.playersLevelTwo = club.playersLevelTwo or {} --初始二级(小队长)合伙人成员列表 club.playersLevelThree = club.playersLevelThree or {} --初始三级(小组长)合伙人成员列表 club.playersMatch = club.playersMatch or {} --初始二级合伙人成员列表 club.unionPlayerList = club.unionPlayerList or {} --合盟亲友圈列表 --排名赛总数据(数据下分各个模块数据)玩家的数据和players保持一样,根据viewType状态机区分 club.allPeopleMatch = club.allPeopleMatch or {} if v.is_coapply then club.isCoapply = tonumber(v.is_coapply)==1 --合伙人添加成员是否需要审核。1需要申请,0无需申请 end --比赛场:0亲友圈关闭,亲友圈功能隐藏,1功能关闭, 创始人可见,2功能开启, 创始人可见 club.isArena = tonumber(v.is_arena) or club.is_arena --0 无需处理; 1 上级发起取消当前合伙人权限通知(弹框) club.cancelCopartner = v.cancelCopartner or club.cancelCopartner --个人可用红花 club.memberInfo = (v.memberInfo) or (club.memberInfo) club.club_bgprop = v.prop or club.club_bgprop or {} --亲友圈背景数据 club.groupext = v.groupext or club.groupext or {} --亲友圈群特性 club.activeGames = v.activeGames or club.activeGames or {} --亲友圈激活的游戏 club.isplaying = v.isplaying or club.isplaying or false --是否在游戏内 club.groupLevel = v.group_level or club.groupLevel or 1 --队长等级(亲友圈等级) club.noticeList = v.noticeList or {} --兼容旧的:隐私战绩 开启后只有创世人和管理员能看到战绩 if club.groupext.cliext then club.isGamb = club.groupext.cliext.is_gamb == 1 else club.isGamb = tonumber(v.is_gamb) == 1 end --兼容旧的:微信分享1禁止微信分享0关闭 if club.groupext.cliext then club.isWxshare = club.groupext.cliext.is_wxshare == 1 else club.isWxshare = tonumber(v.is_wxshare) == 1 end --初始化默认值 if not club.groupext.cliext then club.groupext.cliext = {} end if table.nums(club.groupext.cliext) == 0 or (not club.groupext.cliext.is_privacy) or (not club.groupext.cliext.is_teamHide) or (not club.groupext.cliext.is_managerHide) then club.groupext.cliext.is_privacy = 1 club.groupext.cliext.is_teamHide = 1 club.groupext.cliext.is_managerHide = 1 club.groupext.cliext.is_hideCreator = 1 club.groupext.cliext.is_hideBelong = 1 end -- 隐藏茶馆id if not club.groupext.cliext.is_hideGid then club.groupext.cliext.is_hideGid = 0 end -- 隐藏游戏内选手id if not club.groupext.cliext.is_hideUid then club.groupext.cliext.is_hideUid = 0 end club.isPrivacy = club.groupext.cliext.is_privacy == 1 --合盟开关 club.unionType = tonumber(v.unionType) --0未开启,1代表自己是主盟,2副盟已进入合盟状态 club.unionGid = tonumber(v.unionGid)--unionType是2的情况下,合盟时显示主盟字段 club.unionOwner = tonumber(v.unionOwner)--unionType是2的情况下,合盟时显示uid字段 --小组长开关 club.isCopartner7 = v.is_copartner7 or club.isCopartner7 or 0 app.config.ModuleConfig.IsSupportThirdCopartner = club.isCopartner7 == 1 end --更新俱乐部设置 function ClubProtocolPhp:updateClubSettings(clubId,settings) if not self.clubList[tonumber(clubId)] then --self.clubList[tonumber(clubId)] = {} return end local club = self.clubList[tonumber(clubId)] if not settings or table.nums(settings)==0 then club.settings={} return end if not club.settings then club.settings={} end club.settings.baoJianId = settings.ruleid and tonumber(settings.ruleid) or club.settings.baoJianId club.settings.realGameId = settings.game_id and tonumber(settings.game_id) or club.settings.gameId club.settings.gameId = settings.game_id and tonumber(settings.game_id) or club.settings.gameId club.settings.strGameRule = settings.gamerule or club.settings.strGameRule --规则 local config = getSubGameConfig(club.settings.gameId) if config and config.bSingleGame then local strGameRule = json.decode(club.settings.strGameRule) club.settings.gameId = toNumber(club.settings.gameId) * 10000 + toNumber(strGameRule.gamerule) end club.settings.gameNum = settings.game_num and tonumber(settings.game_num) or club.settings.gameNum --局数 club.settings.orderId = settings.ranking or club.settings.orderId --序列号 club.settings.title = settings.title or club.settings.title --标题 club.settings.arena = settings.arena or club.settings.arena --比赛场设置 club.settings.ext = settings.ext or club.settings.ext -- 扩展信息,json end --更新包间数据到俱乐部设置(切换包间) function ClubProtocolPhp:updateClubSettingsByBaoJian(clubId,baoJianId) local club = self.clubList[tonumber(clubId)] local baojian = self:getBaoJian(clubId,baoJianId) if club and baojian then club.settings.baoJianId = tonumber(baoJianId) club.settings.gameId = baojian.gameId or club.settings.gameId club.settings.realGameId = baojian.gameId or club.settings.gameId club.settings.strGameRule = baojian.strGameRule or club.settings.strGameRule --规则 club.settings.gameNum = baojian.gameNum or club.settings.gameNum --局数 club.settings.orderId = baojian.orderId or club.settings.orderId --序列号 club.settings.title = baojian.title or club.settings.title --标题 club.settings.arena = baojian.arena or club.settings.arena --比赛场设置 club.settings.ext = baojian.ext or club.settings.ext -- 扩展信息,json local config = getSubGameConfig(club.settings.gameId) if config and config.bSingleGame then local strGameRule = json.decode(club.settings.strGameRule) club.settings.gameId = toNumber(club.settings.gameId) * 10000 + toNumber(strGameRule.gamerule) end if toNumber(club.settings.realGameId) > 10000 then club.settings.realGameId = math.floor(toNumber(club.settings.realGameId) / 10000) end end end --更新俱乐部房间列表 function ClubProtocolPhp:updateClubRooms(clubId,rooms,posList) if not self.clubList[tonumber(clubId)] then self.clubList[tonumber(clubId)] = {} end local club = self.clubList[tonumber(clubId)] --改变游戏或者包间就清空数据 if self.bChangeTable then club.rooms={} club.posList={} end if posList and table.nums(posList) > 0 then club.posList = {} for k,posNum in pairs(posList) do club.posList[posNum] = true end end for k,v in pairs(rooms) do self:updateClubRoom(clubId,v) end end function ClubProtocolPhp:updateClubRoom(clubId,v) if not self.clubList[tonumber(clubId)] then return end local club = self.clubList[tonumber(clubId)] if not club.rooms then club.rooms={} end if not club.posList then club.posList={} end club.posList[tonumber(v.pos_number)] = true if not club.rooms[tonumber(v.pos_number)] then club.rooms[tonumber(v.pos_number)] = {} end local room = club.rooms[tonumber(v.pos_number)] room.baoJianId = v.ruleid and tonumber(v.ruleid) or room.baoJianId --包间id room.roomId = v.roomid and tonumber(v.roomid) or room.roomId --房间号 room.pos = v.pos_number and tonumber(v.pos_number) or room.pos --当前位置 room.currentNum = v.current_play_nember and tonumber(v.current_play_nember) or room.currentNum --当前局数 room.totalNum = v.play_number and tonumber(v.play_number) or room.totalNum --总局数 room.status = v.status and tonumber(v.status) or room.status --1未开局(不需要展示当前局数/总数据)2开局(需展示当前局数/总数据) if tonumber(v.createtime) ~= 0 then room.createTime = v.createtime and tonumber(v.createtime) or room.createTime --服务器生成这个桌子的时间 end --玩家列表 room.players = room.players or {} if v.userInfo then if room.status==1 then room.players = {} --清理之前数据 end for _,p in pairsByKeys(v.userInfo) do local palyer = room.players[tonumber(p.uid)] or {} palyer.uid = tonumber(p.uid) palyer.headimgurl = p.headimgurl or palyer.headimgurl palyer.nickname = p.nickname or palyer.nickname palyer.sex = p.sex and tonumber(p.sex) or palyer.sex palyer.state = p.state and tonumber(p.state) or palyer.state-- 0未连接,可判断离线1已登陆,正常为坐下2准备3在玩4在玩过程中离线5准备但离线6坐下但离线 palyer.score = p.score and tonumber(p.score) or palyer.score room.players[palyer.uid] = palyer end end end function ClubProtocolPhp:updateClubBaoJians(clubId,baojians) if not self.clubList[clubId] then self.clubList[clubId] = {} end local club = self.clubList[clubId] club.baoJians={} if baojians then for _,bj in pairs(baojians) do --都为string self:updateClubBaoJian(clubId,bj) end end end function ClubProtocolPhp:updateClubBaoJian(clubId,bj,change) if not bj.ruleid then return end if not self.clubList[clubId] then return --self.clubList[clubId] = {} end local club = self.clubList[clubId] if not club.baoJians then club.baoJians={} end if not club.baoJians[tonumber(bj.ruleid)] then club.baoJians[tonumber(bj.ruleid)] = {} end local baojian = club.baoJians[tonumber(bj.ruleid)] baojian.baoJianId = tonumber(bj.ruleid) or baojian.baoJianId baojian.gameId = tonumber(bj.game_id) or baojian.gameId local config = tonumber(baojian.gameId) and getSubGameConfig(tonumber(baojian.gameId)) or nil if config and config.bSingleGame then local gamerule = json.decode(bj.gamerule).gamerule baojian.gameId = tonumber(bj.game_id) * 10000 + gamerule end baojian.realGameId = baojian.gameId if baojian.gameId and baojian.gameId > 10000 then baojian.realGameId = math.floor(baojian.gameId/10000) end baojian.onlineRoomNum = bj.onlineroom and tonumber(bj.onlineroom) or baojian.onlineRoomNum or 0 baojian.gameNum = tonumber(bj.game_num) or baojian.gameNum baojian.strGameRule = bj.gamerule or baojian.strGameRule baojian.title = bj.title or baojian.title baojian.orderId = tonumber(bj.ranking) or baojian.orderId or table.nums(club.baoJians) --新增包间大赢家设置 baojian.playWinScore = tonumber(bj.play_win_threshold) or baojian.playWinScore or 0 --比赛设置信息 baojian.arena = bj.arena or baojian.arena or "" baojian.is_use = bj.is_use or baojian.is_use or "" baojian.ext = bj.ext or baojian.ext or "" --如果当前俱乐部的设置刚好为当前包间或者第一次添加包间 则需要更新设置数据 if club.settings and (not club.settings.baoJianId or club.settings.baoJianId==baojian.baoJianId) then self:updateClubSettingsByBaoJian(clubId,baojian.baoJianId) end local againid = getAgainGameBaoJianId() if tonumber(baojian.baoJianId) == tonumber(againid) and change == true then setRuleChangeStatus(true) end end --亲友圈消息 function ClubProtocolPhp:updateClubMessages(clubId,messages) if not messages then return end if not self.clubList[clubId] then self.clubList[clubId] = {} end local club = self.clubList[clubId] club.messages={} for _,msg in pairs(messages) do if not club.messages[tonumber(msg.msgid)] then club.messages[tonumber(msg.msgid)] = {} end local messageItem = club.messages[tonumber(msg.msgid)] messageItem.messageId = tonumber(msg.msgid) messageItem.clubId = tonumber(msg.gid) messageItem.content = msg.content messageItem.date = msg.create_time end end --排名赛申请 function ClubProtocolPhp:updateClubMatchMessages(clubId,messages) if not messages then return end if not self.clubList[clubId] then self.clubList[clubId] = {} end local club = self.clubList[clubId] club.matchMessages={} for _,msg in pairs(messages) do if not club.matchMessages[tonumber(msg.id)] then club.matchMessages[tonumber(msg.id)] = {} end local messageItem = club.matchMessages[tonumber(msg.id)] messageItem.messageId = tonumber(msg.id) messageItem.clubId = tonumber(msg.gid) messageItem.uid = tonumber(msg.uid) messageItem.nick = msg.nick or "" messageItem.strHeadUrl = msg.icon or "" messageItem.role = tonumber(msg.role) messageItem.warnum = tonumber(msg.warnum) messageItem.applyTime = tonumber(msg.apply_time) messageItem.endTime = tonumber(msg.end_time) messageItem.status = tonumber(msg.status) messageItem.copartner = tonumber(msg.copartner) messageItem.operuid = tonumber(msg.operuid) end end --海选赛申请 function ClubProtocolPhp:updateClubCestMessages(clubId,messages) if not messages then return end if not self.clubList[clubId] then self.clubList[clubId] = {} end local club = self.clubList[clubId] club.cestMessages={} for _,msg in pairs(messages) do if not club.cestMessages[tonumber(msg.id)] then club.cestMessages[tonumber(msg.id)] = {} end local messageItem = club.cestMessages[tonumber(msg.id)] messageItem.messageId = tonumber(msg.id) messageItem.clubId = tonumber(msg.gid) messageItem.uid = tonumber(msg.uid) messageItem.nick = msg.nick or "" messageItem.icon = msg.icon or "" messageItem.role = tonumber(msg.role) -- messageItem.warnum = tonumber(msg.warnum) -- messageItem.cestext = msg.cestext messageItem.copartner = tonumber(msg.copartner) messageItem.copartner_nick = msg.copartner_nick messageItem.copartner = tonumber(msg.copartner) messageItem.contribute = tonumber(msg.contribute) messageItem.point = tonumber(msg.point) -- 积分 messageItem.type = tonumber(msg.type) messageItem.applyTime = tonumber(msg.apply_time) messageItem.endTime = tonumber(msg.end_time) messageItem.status = tonumber(msg.status) messageItem.operuid = tonumber(msg.operuid) end end --奖励消息 function ClubProtocolPhp:updateClubAwardMessages(clubId,messages) if not messages then return end if not self.clubList[clubId] then self.clubList[clubId] = {} end local club = self.clubList[clubId] if not club.awardMessages then club.awardMessages={} end for _,msg in pairs(messages) do if not club.awardMessages[tonumber(msg.awardid)] then club.awardMessages[tonumber(msg.awardid)] = {} end local messageItem = club.awardMessages[tonumber(msg.awardid)] messageItem.awardId = tonumber(msg.awardid) messageItem.awardSN = tonumber(msg.awardsn) messageItem.content = msg.content messageItem.status = tonumber(msg.status) end end -- 更新玩家申请消息列表 -- @param clubId 俱乐部id -- @param messages 消息列表 -- @msgType 消息类型,1为加入申请,2为退出申请 function ClubProtocolPhp:updateClubApplyMessages(clubId,messages,msgType) if not messages then return end if not self.clubList[clubId] then self.clubList[clubId] = {} end local club = self.clubList[clubId] if not club.applyMessages then club.applyMessages={} end if not club.coapplyMessages then club.coapplyMessages={} end for i,msg in pairs(messages) do local index = msg.uid.."_"..msgType --数据类型msg.type{1普通成员申请, 2合伙人的成员申请} if tonumber(msg.type) == 2 or tonumber(msg.type) == 3 then -- todo lwq 添加type == 3 --合伙人的成员申请 if not club.coapplyMessages[index] then club.coapplyMessages[index] = {} end local messageItem = club.coapplyMessages[index] messageItem.uid = tonumber(msg.uid) messageItem.clubId = tonumber(msg.gid) messageItem.clubName = msg.gname messageItem.name = msg.nick messageItem.sex = tonumber(msg.sex) messageItem.strHeadUrl = msg.icon messageItem.applyTime = tonumber(msg.apply_time) messageItem.joinTime = tonumber(msg.join_time) messageItem.status = tonumber(msg.status) --0申请1通过2拒绝 messageItem.copartner = tonumber(msg.copartner) messageItem.copartner_nick = msg.copartner_nick messageItem.copartner5 = tonumber(msg.copartner5) messageItem.copartner5_nick = msg.copartner5_nick messageItem.copartner6 = tonumber(msg.copartner6) messageItem.copartner6_nick = msg.copartner6_nick messageItem.copartner7 = tonumber(msg.copartner7) messageItem.copartner7_nick = msg.copartner7_nick messageItem.operuid = tonumber(msg.operuid) messageItem.opernick = msg.opernick messageItem.index = index --前端默认添加key messageItem.msgType = msgType -- 前端加入的key,标志申请消息类型 else --普通成员申请 if not club.applyMessages[index] then club.applyMessages[index] = {} end local messageItem = club.applyMessages[index] messageItem.uid = tonumber(msg.uid) messageItem.clubId = tonumber(msg.gid) messageItem.clubName = msg.gname messageItem.name = msg.nick messageItem.sex = tonumber(msg.sex) messageItem.strHeadUrl = msg.icon messageItem.applyTime = tonumber(msg.apply_time) messageItem.joinTime = tonumber(msg.join_time) messageItem.status = tonumber(msg.status) --0申请1通过2拒绝 messageItem.index = index --前端默认添加key messageItem.msgType = msgType -- 前端加入的key,标志申请消息类型 end end end function ClubProtocolPhp:updateClubApplyMessageStatus(clubId,index,status,id,name) local club = self.clubList[clubId] if not club then return end if club.applyMessages then for i,msg in pairs(club.applyMessages) do if msg.index==index then msg.status = status end end end if club.coapplyMessages then for i,msg in pairs(club.coapplyMessages) do if msg.index==index then msg.status = status if id and name then msg.operuid = id msg.opernick = name end end end end end function ClubProtocolPhp:updateClubMatchMessageApplyStatus(clubId,messageId,status,id,name) local club = self.clubList[clubId] if not club then return end if club.matchMessages then for i,msg in pairs(club.matchMessages) do if msg.messageId==messageId then msg.status = status end end end end function ClubProtocolPhp:updateClubPlayers(clubId,players,mType,dateType) if not players then return end if not self.clubList[clubId] then --self.clubList[clubId] = {} return end local club = self.clubList[clubId] if club.playersMatch then for k,v in pairs(club.playersMatch) do v.viewType = nil end end local pagePlayerList = {} for k,v in pairs(players) do local player = self:updateClubPlayer(clubId,v,nil,mType,dateType) if player then table.insert(pagePlayerList,player) end end return pagePlayerList end function ClubProtocolPhp:updateClubPlayer(clubId,v,isModified,mType,dateType) if not self.clubList[clubId] or not v then return -- self.clubList[clubId] = {} end mType = mType or ClubDefine.PlayListType.NORMAL_MEMBER local club = self.clubList[clubId] if not club.players then club.players={} end if not club.playersLevelOne then club.playersLevelOne={} end if not club.playersLevelTwo then club.playersLevelTwo={} end if not club.playersLevelThree then club.playersLevelThree={} end if not club.playersMatch then club.playersMatch={} end local curPlayerData = nil if mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_MEMBER or mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_RECORD or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER then curPlayerData = club.playersLevelOne elseif mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER or mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_RECORD or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER then curPlayerData = club.playersLevelTwo elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then curPlayerData = club.playersLevelThree elseif mType == ClubDefine.PlayListType.MATCH_MEMBER or mType == ClubDefine.PlayListType.MATCH_RECORD or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_RANK or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LEVEL or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST_TEAM or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_SET_MEMBER then curPlayerData = club.playersMatch else curPlayerData = club.players end if not curPlayerData[tonumber(v.uid)] then if isModified then --如果是修改没有数据直接return return end curPlayerData[tonumber(v.uid)] = {} end local player = curPlayerData[tonumber(v.uid)] player.viewType = mType player.uid = v.uid and tonumber(v.uid) or player.uid player.name = v.nick or player.name player.sex = tonumber(v.sex) or player.sex --玩家性别:0未知1男2女 player.strHeadUrl = v.icon or player.strHeadUrl --玩家头像地址 player.desc = v.desc or player.desc --备注 player.lastPlayNum = v.last_play_number or player.lastPlayNum --昨日局数 player.lastPlayWinNum = v.last_play_win_number or player.lastPlayWinNum --昨日大赢家次数 player.online = tonumber(v.online) or player.online --1在线0离线 player.loginTime = tonumber(v.login_time) or player.loginTime --最近登录的时间戳, 如果数值为0, 直接为离线 player.role = tonumber(v.role) or player.role or 0 --1成员2管理员3创建人 player.status = tonumber(v.status) or player.status or 0 --1正常0黑名单成员-1退出群 player.lastTotalScore = v.last_total_score or player.lastTotalScore --昨日输赢积分 player.copartner = tonumber(v.copartner) or player.copartner --所属普通合伙人/二级合伙人/直属上级UID player.copartner_role = v.copartner_role or player.copartner_role --所属普通合伙人/二级合伙人 player.copartner_nick = v.copartner_nick or player.copartner_nick --所属普通合伙人/二级合伙人/战队名 player.copartner5 = tonumber(v.copartner5) or player.copartner5 --所属一级合伙人ID player.copartner5_nick = v.copartner5_nick or player.copartner5_nick --所属一级合伙人NICK player.notdesk = v.notdesk or 0 -- 禁止同队标志 player.date = v.date or player.date --ljx 日期 小红点转用 player.isred = v.isred or player.isred --ljx 是否显示小红点 --数据分类处理,防止数据重复覆盖 if mType == ClubDefine.PlayListType.MATCH_MEMBER or mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_MEMBER or mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER or (mType == ClubDefine.PlayListType.SEARCH_PLAYER and dateType == ClubDefine.PlayListType.MATCH_MEMBER) then player.totalRedFlower = v.arena_opertotal or player.totalRedFlower or 0 --总红花数(加减总计) player.useRedFlower = v.arena_score or player.useRedFlower or 0 -- 可用红花 player.arenaRatio = v.arena_ratio or player.arenaRatio or 0 -- 分成比例 player.copartnerSubStatus = v.copartnerSubStatus or player.copartnerSubStatus or 0 -- 对合伙人有效, 1表示可冻结所有下属0表示解冻,-1无权对此合伙人批量处理/或是成员 player.cancelDesc = v.cancel_desc or player.cancelDesc or "" --取消确认中的提示 player.haveRole6 = v.haveRole6 or player.haveRole6 or 0 --该1级合伙人名下含有的二级数量 if player.uid == app.user.loginInfo.uid and club.memberInfo then club.memberInfo.arena_score = player.useRedFlower self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_RED_FLOWER}) end elseif mType == ClubDefine.PlayListType.MATCH_RECORD or mType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_RECORD or mType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_RECORD or (mType == ClubDefine.PlayListType.SEARCH_PLAYER and dateType == ClubDefine.PlayListType.MATCH_RECORD) then player.changeRedFlower = v.arena_score or player.changeRedFlower or 0-- 红花变动(按日期统计) player.changeGreen = v.arena_profit or player.changeGreen or 0 -- 绿叶变动(按日期统计) player.playNum = v.play_number or player.playNum or 0 --局数 player.playWinNum = v.play_win_number or player.playWinNum or 0 --大赢家次数 player.totalScore = v.total_score or player.totalScore or 0 --输赢积分 elseif mType == ClubDefine.PlayListType.NORMAL_MEMBER then player.agent = v.agent or player.agent --1是代理0不是代理 player.playNum = v.play_number or player.playNum --局数 player.playWinNum = v.play_win_number or player.playWinNum --大赢家次数 player.totalScore = v.total_score or player.totalScore --输赢积分 elseif mType == ClubDefine.PlayListType.INVITE_ONLINE then if v.isplay then player.isPlay = v.isplay == 1 --是否在游戏中(1:游戏中) end elseif mType == ClubDefine.PlayListType.MATCH_RANK then player.changeRedFlower = v.arena_score or player.changeRedFlower -- 红花变动(按日期统计) elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_RANK then player.captainLevel = tonumber(v.captain_level) or player.captainLevel--当前队长等级 player.useMedal = tonumber(v.use_medal) or player.useMedal --已使用勋章 player.medal = tonumber(v.medal) or player.medal --战队勋章 player.warnum = tonumber(v.warnum) or player.warnum --排名分 player.warreward = tonumber(v.warreward) or player.warreward --月排名奖 player.ranking = tonumber(v.ranking) or player.ranking --排名 player.level = tonumber(v.user_level) or player.level --玩牌等级 player.rewardType = tonumber(v.rewardType) or player.rewardType --奖励类型 -- cest if self:getCestIsOpen(clubId) then player.contribute = tonumber(v.contribute) or player.contribute or 0 -- 赛点 player.play_gamenum = tonumber(v.play_gamenum) or player.play_gamenum or 0 -- 参赛人次 player.totalscore = tonumber(v.totalscore ) or player.totalscore or 0 -- 技术分 player.av_win = tonumber(v.av_win) or player.av_win or 0 -- 平均胜率 player.win_num = tonumber(v.win_num) or player.win_num or 0 -- 冠军数量 player.applynums = tonumber(v.applynums) or player.applynums or 0 -- 战队战况,总的 player.curapplynums = tonumber(v.curapplynums) or player.curapplynums or 0 -- 战队战况,当前 local playerInfo1 = app.club_php:getPlayer(self.clubId,player.uid) if not playerInfo1 then return end end elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LEVEL then player.captainLevel = tonumber(v.captain_level) or player.captainLevel --当前队长等级 player.medal = tonumber(v.medal) or player.medal --战队勋章 player.endMedal = tonumber(v.end_medal) or player.endMedal --下一级需要的勋章 player.startMedal = tonumber(v.start_medal) or player.startMedal --下一级提升的勋章 elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LIST_TEAM or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_SET_MEMBER or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER or mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then --玩家数据 player.haveRole6 = v.haveRole6 or player.haveRole6 or 0 --该1级合伙人名下含有的二级数量 player.captainLevel = tonumber(v.captain_level) or player.captainLevel --当前队长等级 player.level = tonumber(v.user_level) or player.level or 1 --玩牌等级 player.warnum = tonumber(v.warnum) or player.warnum --排名分 player.arenaSprint = tonumber(v.arena_sprint) or player.arenaSprint --初始化分 player.arenaReport = tonumber(v.arena_report) or player.arenaReport --上报分 player.playNum = tonumber(v.play_number) or player.playNum --局数 player.playWinNum = tonumber(v.play_win_number) or player.playWinNum --大赢家次数 player.totalScore = v.total_score or player.totalScore --输赢积分 player.honor = tonumber(v.honor) or player.honor --抽奖 player.copartner6 = v.copartner6 or player.copartner6 --所属二级合伙人ID player.copartner7 = v.copartner7 or player.copartner7 --所属三级合伙人(小组长)ID player.arenaRatio = v.arena_ratio or player.arenaRatio or 0 -- 分成比例 player.copartnerSubStatus = v.copartnerSubStatus or player.copartnerSubStatus or 0 -- 对合伙人有效, 1表示可冻结所有下属0表示解冻,-1无权对此合伙人批量处理/或是成员 player.grant = v.grant or player.grant or 0 --管理员所拥有的权限(裁判,上报排名,指派出赛) player.play_number = v.play_number or player.play_number or 0 --参赛总局数 -- cest if self:getCestIsOpen(clubId) then player.point = v.point or player.point or 0 --积分 player.contribute = v.contribute or player.contribute or 0 -- 赛点 player.totalscore = v.totalscore or player.totalscore or 0 -- 技术分 player.totalnum = v.totalnum or player.totalnum or 0 -- 轮次 player.maxcontribute = tonumber(v.maxcontribute) or player.maxcontribute or 0 -- 最高赛点 player.gamenum = v.gamenum or player.gamenum or 0 -- 本轮总轮次 player.curgamenum = v.curgamenum or player.curgamenum or 0 -- 本轮使用轮次 player.m_sumtotalscore = v.m_sumtotalscore or player.m_sumtotalscore or 0 -- 总技术分 player.isJsfOrZf = 0 -- 技术分或者总技术分,0:技术分,1:总技术分 end if player.uid == app.user.loginInfo.uid and club.memberInfo then club.memberInfo.warnum = player.warnum self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_RED_FLOWER}) end end return player end --更新排名赛数据 function ClubProtocolPhp:updateAllPeopleMatchData(clubId,data,mType) if not self.clubList[clubId] or not data or not mType then return end local club = self.clubList[clubId] if not club.allPeopleMatch then club.allPeopleMatch = {} end if mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_RANK then --排名赛排名数据allRankList if not club.allPeopleMatch.allRankList then club.allPeopleMatch.allRankList = {} end club.allPeopleMatch.allRankList.sLastDay = data.sLastDay or club.allPeopleMatch.allRankList.sLastDay club.allPeopleMatch.allRankList.groupCfg = data.groupCfg or club.allPeopleMatch.allRankList.groupCfg elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_RANK then --排名赛战队排名数据allTeamRankList if not club.allPeopleMatch.allTeamRankList then club.allPeopleMatch.allTeamRankList = {} end club.allPeopleMatch.allTeamRankList.memberCfg = data.memberCfg or club.allPeopleMatch.allTeamRankList.memberCfg club.allPeopleMatch.allTeamRankList.stat = data.stat or club.allPeopleMatch.allTeamRankList.stat elseif mType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER then --排名赛管理 if not club.allPeopleMatch.allManage then club.allPeopleMatch.allManage = {} end club.allPeopleMatch.allManage.sLastDay = data.sLastDay or club.allPeopleMatch.allManage.sLastDay club.allPeopleMatch.allManage.stat = data.stat or club.allPeopleMatch.allManage.stat elseif mType == ClubDefine.PlayListType.UNION_CLUB_LIST then --联盟亲友圈列表成员 if not club.allPeopleMatch.allUnion then club.allPeopleMatch.allUnion = {} end club.allPeopleMatch.allUnion.sLastDay = data.sLastDay or club.allPeopleMatch.allUnion.sLastDay club.allPeopleMatch.allUnion.stat = data.stat or club.allPeopleMatch.allUnion.stat end end --获取排名配置 function ClubProtocolPhp:getMatchRankConfig(clubId) local club = self.clubList[clubId] if not club or not club.allPeopleMatch or not club.allPeopleMatch.allRankList or not club.allPeopleMatch.allRankList.groupCfg then return nil end return club.allPeopleMatch.allRankList.groupCfg end --获取排名赛排名数据 function ClubProtocolPhp:getMatchRank(clubId) local club = self.clubList[clubId] if not club or not club.allPeopleMatch or not club.allPeopleMatch.allRankList then return nil end return club.allPeopleMatch.allRankList end --获取战队/小队排名数据 function ClubProtocolPhp:getMatchTeamRank(clubId) local club = self.clubList[clubId] if not club or not club.allPeopleMatch or not club.allPeopleMatch.allTeamRankList then return nil end return club.allPeopleMatch.allTeamRankList end --获取排名赛管理数据 function ClubProtocolPhp:getMatchManage(clubId) local club = self.clubList[clubId] if not club or not club.allPeopleMatch or not club.allPeopleMatch.allManage then return nil end return club.allPeopleMatch.allManage end --获取合盟亲友圈列表数据 function ClubProtocolPhp:getMatchUnionList(clubId) local club = self.clubList[clubId] if not club or not club.allPeopleMatch or not club.allPeopleMatch.allUnion then return nil end return club.allPeopleMatch.allUnion end function ClubProtocolPhp:getRoomData(clubId,index) local club = self.clubList[clubId] if not club or not club.rooms then return nil end return club.rooms[index] end function ClubProtocolPhp:getBaoJianByGameId(clubId,gameId) local tt = {} local club = self.clubList[clubId] if not club or not club.baoJians then return tt end for k,v in pairs(club.baoJians) do if tonumber(v.gameId) == tonumber(gameId) then table.insert(tt,v) end end return tt end function ClubProtocolPhp:getGameIdByBaoJianId(clubId,baoJianId) local club = self.clubList[clubId] if not club or not club.baoJians then return 0 end for k,v in pairs(club.baoJians) do if tonumber(v.baoJianId) == tonumber(baoJianId) then return v.gameId end end end function ClubProtocolPhp:getBaoJian(clubId,ruleId) local club = self.clubList[clubId] if not club or not club.baoJians then return nil end return club.baoJians[tonumber(ruleId)] end function ClubProtocolPhp:getBaoJianRooms(clubId,baoJianId) local rooms = {} local club = self.clubList[clubId] if club then for k,v in pairsByKeys (club.rooms) do if v.baoJianId == baoJianId then table.insert(rooms,v) end end end return clone(rooms) end function ClubProtocolPhp:getClubRooms(clubId) local rooms = {} local club = self.clubList[clubId] if club then for k,v in pairsByKeys (club.rooms) do table.insert(rooms,v) end end return clone(rooms) end function ClubProtocolPhp:getSortClubBaoJians(clubId,baoJians) local newBaoJians = {} local club = self.clubList[clubId] local tt = baoJians or club.baoJians if tt then for k,v in pairs(tt) do table.insert(newBaoJians,v) end table.sort(newBaoJians,function (a,b) if a.baoJianId and b.baoJianId then return a.baoJianId < b.baoJianId else return false end end) return newBaoJians end return {} end function ClubProtocolPhp:getSortClubRooms(clubId) local rooms = {} local club = self.clubList[clubId] if club then for k,v in pairsByKeys(club.rooms) do table.insert(rooms,v) end --Tarry:未开局(桌子越老排前面) — 新开局 (桌子越新排前面) local function sortRoom(a,b) local numA = a.createTime or -1 local numB = b.createTime or -1 if a.status==1 and b.status~=1 then return true elseif a.status==1 and b.status==1 then if numA numB then return true end end return false end table.sort(rooms,sortRoom) end return clone(rooms) end --查找我所在的房间 function ClubProtocolPhp:getMyInRoom(clubId) local clubInfo = self.clubList[tonumber(clubId)] local inRoom = false if clubInfo then inRoom = clubInfo.isplaying == 1 end return inRoom end function ClubProtocolPhp:delBaoJian(clubId,baoJianId) local club = self.clubList[clubId] if not club or not club.baoJians or not club.baoJians[baoJianId] then return end club.baoJians[baoJianId].is_use = 0 end function ClubProtocolPhp:getUnionClubId(clubId,sgid) if not clubId then return end local club = self.clubList[clubId] if club and club.unionPlayerList then return club.unionPlayerList[sgid] end return nil end function ClubProtocolPhp:getPlayer(clubId,uid,viewType) if not clubId then return end local club = self.clubList[clubId] if self:getMatchIsOpen(clubId) then if club then if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER and club.playersLevelOne then return club.playersLevelOne[uid] elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER and club.playersLevelOne then return club.playersLevelTwo[uid] elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER and club.playersLevelOne then return club.playersLevelThree[uid] else return club.playersMatch[uid] end end elseif self:getCestIsOpen(clubId) then if club then if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER and club.playersLevelOne then return club.playersLevelOne[uid] elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER and club.playersLevelOne then return club.playersLevelTwo[uid] elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER and club.playersLevelOne then return club.playersLevelThree[uid] else return club.playersMatch[uid] end end else if club and club.players then return club.players[uid] end end return nil end function ClubProtocolPhp:getMatchPlayer(clubId,uid,viewType) return self:getPlayer(clubId,uid,viewType) end function ClubProtocolPhp:getPlayerNum(settings) if not settings then return 4 end local gameId = settings.realGameId local ruleInfo = json.decode(settings.strGameRule) local gameRule = ruleInfo.gamerule or ruleInfo.gameRule -- 子游戏不要使用gameRule,统一使用gamerule local playerNum = ruleInfo.playnum or getSubGamePlayerNum(gameId, gameRule) -- if playerNum==-1 or playerNum==1 then --字牌快速开始为-1,1 -- playerNum = 4 -- end if playerNum<2 then --如果人数小于2 默认为4 playerNum = 4 end if ruleInfo.isfaststart == 1 then --鬼麻将快速开始为1 if gameId == 42 or gameId == 27 or gameId == 55 then -- 42自贡麻将、27三人两房、55三人三房特殊处理,最多3人玩 playerNum = 3 elseif gameId == 64 then -- 自贡七张麻将 playerNum = 6 else playerNum = 4 end end if ruleInfo.isHongZhong == 1 then playerNum = (ruleInfo.playnum == 0) and 2 or (ruleInfo.playnum == 1 and 3 or 4) end return playerNum end function ClubProtocolPhp:onPhpMessage(event) if not event or not event.msg or type(event.msg) ~= "table" then return end local message = event.msg local msgType = message.type and tonumber(message.type) or nil if msgType == ClubDefine.PUSH.changeBaoJian then --更新包间玩法 注意 gid type 都为number 其他为string local clubId = tonumber(message.gid) local content = message.content if message.content.type == 0 then --删除 self:delBaoJian(clubId,tonumber(content.ruleid)) --刷新包间管理 self:dispatchEvent({name = GAME_EVENT.CLUB_CALUATE_ACTIVE_GAME}) self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE}) self:requestClubHome(clubId,nil,nil,0) --修改后需要刷新桌子 elseif message.content.type == 1 then --修改 self:updateClubBaoJian(clubId,content,true) self:requestClubHome(clubId,nil,nil,0) --修改后需要刷新桌子 self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE}) elseif message.content.type == 2 then --新增 self:updateClubBaoJian(clubId,content) local clubInfo = self.clubList[tonumber(clubId)] if clubInfo and content.activeGames then clubInfo.activeGames = content.activeGames end self:dispatchEvent({name = GAME_EVENT.CLUB_CALUATE_ACTIVE_GAME}) self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE,clubId = clubId,baoJianId = tonumber(content.ruleid)}) self:requestClubHome(clubId,nil,nil,0) --修改后需要刷新桌子 end elseif msgType == ClubDefine.PUSH.setAllBaoJian then local clubId = tonumber(message.gid) if message.content then --[[logD("content:",table.tostring(message.content)) for baoJianId,v in pairs(message.content) do self:updateClubBaoJian(clubId,v) end--]] self:requestClubHome(clubId) self:dispatchEvent({name = GAME_EVENT.CLUB_SET, clubId = clubId}) --self:dispatchEvent({name = GAME_EVENT.CLUB_ROOM_BAOJIAN_UPDATE, clubId = clubId}) end elseif msgType == ClubDefine.PUSH.changeBaoJianSet then --更新包间名 local clubId = tonumber(message.gid) self:updateClubBaoJian(clubId,message.content) self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE_PUSH, clubId = clubId}) elseif msgType == ClubDefine.PUSH.clubJieSan then --解散茶馆 local clubId = tonumber(message.gid) self:requestClubList() if app.club_php:getCestIsOpen(clubId) then message.content = string.gsub(message.content, "亲友圈", "赛事") end if self.clubList and self.clubList[clubId] then -- todo lwq 不加判断的话,没拉取clublist信息有问题 if self.clubList[clubId].role ~= 3 then showTooltip(message.content) end end self.clubList[clubId] = nil self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) self:dispatchEvent({name = GAME_EVENT.CLUB_JIE_SAN , clubId = clubId}) elseif msgType == ClubDefine.PUSH.changeClubName then --修改茶馆名字 local clubId = tonumber(message.gid) local content = json.decode(message.content or "") if self.clubList[clubId] and content then self.clubList[clubId].clubName = content.gname or self.clubList[clubId].clubName end -- self:updateClub(clubId,message.content) self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH}) elseif msgType == ClubDefine.PUSH.dongJieClub or msgType == ClubDefine.PUSH.jieDongClub then --解冻 冻结茶馆 local clubId = tonumber(message.gid) local content = json.decode(message.content or "") if self.clubList[clubId] and content then self.clubList[clubId].status = content.status and tonumber(content.status) or self.clubList[clubId].status end self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH}) elseif msgType == ClubDefine.PUSH.changeClubSet then --茶馆设置修改 local clubId = tonumber(message.gid) local content = json.decode(message.content or "") if not clubId then return end if not content then return end local clubInfo = self.clubList[clubId] if not clubInfo then return end if self.clubList[clubId] and content then if content.is_privacy then self.clubList[clubId].isPrivacy = tonumber(content.is_privacy)==1 --隐私1开启隐私0默认关闭 -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_LIST}) end if content.room_mode then self.clubList[clubId].mode = tonumber(content.room_mode) --茶馆模式 -- 模式发生变化,需要重新更新桌子列表 self.clubList[clubId].rooms = {} self:requestClubHome(clubId) end if content.is_gamb then self.clubList[clubId].isGamb = tonumber(content.is_gamb) == 1 end if content.is_coapply then self.clubList[clubId].isCoapply = tonumber(content.is_coapply) == 1 end if content.is_wxshare then self.clubList[clubId].isWxshare = tonumber(content.is_wxshare)==0 -- 0微信分享 end if content.is_apply then self.clubList[clubId].isApply = tonumber(content.is_apply) == 1 end if content.is_exitapply then self.clubList[clubId].isExitApply = tonumber(content.is_exitapply) == 1 end if content.groupext then if not self.clubList[clubId].groupext then self.clubList[clubId].groupext = {} end if content.groupext.playext and type(content.groupext.playext) == "string" then self.clubList[clubId].groupext.playext = json.decode(content.groupext.playext) end if content.groupext.is_gps then self.clubList[clubId].groupext.is_gps = tonumber(content.groupext.is_gps) end if content.groupext.gps_limit then self.clubList[clubId].groupext.gps_limit = tonumber(content.groupext.gps_limit) end if content.groupext.cliext and type(content.groupext.cliext) == "string" then self.clubList[clubId].groupext.cliext = json.decode(content.groupext.cliext) end if content.groupext.is_playerpri then self.clubList[clubId].groupext.is_playerpri = tonumber(content.groupext.is_playerpri) end end if content.gname then if self.clubList[clubId] and content then self.clubList[clubId].clubName = content.gname or self.clubList[clubId].clubName end end if content.is_arena then self.clubList[clubId].isArena = content.is_arena or clubInfo.isArena self:dispatchEvent({name = GAME_EVENT.CLUB_SET,setType = GAME_CLUB_SET_STATE.Math_Switch}) end end self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH}) elseif msgType == ClubDefine.PUSH.changePlayer then --成员修改 local clubId = tonumber(message.gid) local viewType = toNumber(message.content.viewType) or 0 --合盟模式有些数据和排名赛一样,比如排名分,上报分,裁判等走了10022的通道,viewType下发是副盟模式,需要改为排名赛 if self:getIsUnion(clubId) and viewType == ClubDefine.PlayListType.UNION_CLUB_LIST then viewType = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER end if message.content.type == 0 then --删除成员 local uids = message.content.delUids if self.clubList[clubId] and uids then if self.clubList[clubId].playersLevelOne then for k,uid in pairs(uids) do self.clubList[clubId].playersLevelOne[tonumber(uid)] = nil end end if self.clubList[clubId].playersLevelTwo then for k,uid in pairs(uids) do self.clubList[clubId].playersLevelTwo[tonumber(uid)] = nil end end if self.clubList[clubId].playersLevelThree then for k,uid in pairs(uids) do self.clubList[clubId].playersLevelThree[tonumber(uid)] = nil end end if self.clubList[clubId].playersMatch then for k,uid in pairs(uids) do self.clubList[clubId].playersMatch[tonumber(uid)] = nil end end for k,uid in pairs(uids) do self.clubList[clubId].players[tonumber(uid)] = nil end self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST}) end elseif message.content.type == 1 then --新增成员 local members = message.content.members for k,v in pairs(members) do self:updateClubPlayer(clubId,v,nil,viewType) end --self:requestClubList()如果是在俱乐部列表界面想刷新人数,被动刷新比较好,不要主动下发 --这里的ViewType是服务器主动下发的,空的,后续需要分发到界面,然后由界面去请求,这样可以请求到某一天的列表 self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST}) elseif message.content.type == 2 then --修改成员权限 local members = message.content.members for k,v in pairs(members) do --比赛场:在一级下属界面修改了一级合伙人的冻结权限,在比赛成员界面需要更新权限,类似的还有二级 if (viewType == ClubDefine.PlayListType.MATCH_LV_1_COPARTNER_MEMBER and v.role == ClubDefine.Job.LevelOneCopartner) or (viewType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER and v.role == ClubDefine.Job.LevelTwoCopartner) then self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.MATCH_MEMBER) end --全民赛:在队长下属界面修改了队长的冻结权限等操作,在全民赛管理界面需要更新权限,类似的还有小队长,小组长 if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER) self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER}) end --全民赛:在小队长下属界面修改了小队长数据,需要刷新队长。 if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER) self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER}) end --全民赛:在小组长下属界面修改了小组长数据,需要刷新小队长。 if viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then self:updateClubPlayer(clubId,v,true,ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER) self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER}) end self:updateClubPlayer(clubId,v,true,viewType) if v.uid==tonumber(app.user.loginInfo.uid) and v.role then--更新茶馆角色信息 if self.clubList[clubId] and self.clubList[clubId].role ~= tonumber(v.role) then self.clubList[clubId].role = tonumber(v.role) --取消 if self.clubList[clubId].role ~= ClubDefine.Job.Manager and self.clubList[clubId].role ~= ClubDefine.Job.Creator then if self.clubList[clubId].groupext then self.clubList[clubId].groupext.is_playerpri = 1 end end self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_ROLE}) self:dispatchEvent({name = GAME_EVENT.CLUB_TABLE, clubId = clubId}) end end -- 海选赛修改权限,就修改消息:海选赛申请(管理员、队长和小队长的权限) if app.club_php:getCestIsOpen(clubId) then if v.grant then self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_UPDATE_APPLY_LIST}) end end end if viewType == ClubDefine.PlayListType.MATCH_MEMBER then self:dispatchEvent({name = GAME_EVENT.UPDATE_COPARTNER_RATDIO}) end end self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_LIST,type = viewType}) self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = viewType}) elseif msgType == ClubDefine.PUSH.kickClubPlayer then --踢出茶馆 local clubId = tonumber(message.gid) self.clubList[clubId] = nil -- 客户端自己改好了,有空再叫老麦改 message.content = string.gsub(message.content, "馆主", "主办人") message.content = string.gsub(message.content, "退群", "退出赛事") message.content = string.gsub(message.content, "亲友圈", "赛事") message.content = string.gsub(message.content, "创始人", "主办人") showTooltip(message.content) self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) self:dispatchEvent({name = GAME_EVENT.CLUB_JIE_SAN, clubId = clubId}) --由于被踢出去了,之前打开的操作界面要关闭 self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_ROLE}) elseif msgType == ClubDefine.PUSH.applyClubSuccess then --申请茶馆成功 local clubId = tonumber(message.gid) -- showTooltip(message.content) self:requestClub(clubId) self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) elseif msgType == ClubDefine.PUSH.changeRoom then --更新房间数据 local clubId = tonumber(message.gid) local content = json.decode(message.content or "") if not clubId then logD("ClubProtocolPhp:onPhpMessage() clubId is nil") return end if not content then logD("ClubProtocolPhp:onPhpMessage() content is nil") return end local clubInfo = self.clubList[clubId] if not clubInfo then logD("ClubProtocolPhp:onPhpMessage() clubInfo is nil") return end if not self:isNeedUpdateTable(clubId,content.ruleid) then logD("ClubProtocolPhp:onPhpMessage() not need update table") return end local isUpdateTable = false local isTableNumChanged = false; -- 房间数量是否发生变化 if content then local contentType = tonumber(content.type) if content.userInfo and table.nums(content.userInfo) == 0 then --没有人在房间则删除房间 if self.clubList[clubId] and self.clubList[clubId].rooms then self.clubList[clubId].rooms[tonumber(content.pos_number)] = nil self.clubList[clubId].posList[tonumber(content.pos_number)] = false isUpdateTable = true isTableNumChanged = true end else --没有房间为新增 if self.clubList[clubId] and self.clubList[clubId].rooms and not self.clubList[clubId].rooms[tonumber(content.pos_number)] then isUpdateTable = true isTableNumChanged = true end local status,statusNew if contentType == 1 then --所有数据 status = content.status self:updateClubRoom(clubId,content) statusNew = self.clubList[clubId].rooms[tonumber(content.pos_number)].status elseif contentType == 2 then --部分数据 需要判断房间数据是否存在不存在丢弃 if self.clubList[clubId] and self.clubList[clubId].rooms and self.clubList[clubId].rooms[tonumber(content.pos_number)] then status = self.clubList[clubId].rooms[tonumber(content.pos_number)].status self:updateClubRoom(clubId,content) statusNew = self.clubList[clubId].rooms[tonumber(content.pos_number)].status end end --未开局变为已开局的时候需要刷新 if status == 1 and statusNew == 2 then isTableNumChanged = true end end end logD("ClubProtocolPhp:onPhpMessage() isTableNumChanged = ", tostring(isTableNumChanged)) -- 桌子数量发生变化则更新桌子列表,否则只更新发生变化的桌子 if isTableNumChanged then local baoJian = self:getBaoJian(clubId,content.ruleid) local gameId = baoJian.gameId self:dispatchEvent({name = GAME_EVENT.CLUB_ROOM_LIST_UPDATE, clubId = clubId,gameId = gameId}) else self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_TABLE, clubId = clubId, pos = tonumber(content.pos_number)}) end elseif msgType == ClubDefine.PUSH.changeClubNotice then --更新公告 local clubId = tonumber(message.gid) if self.clubList[clubId] then self.clubList[clubId].noticeInfo = message.content self.clubList[clubId].notice = message.content.notice end self:dispatchEvent({name = GAME_EVENT.CLUB_NOTICE}) -- local content = json.decode(message.content or "") elseif msgType == ClubDefine.PUSH.changeClubTableNum then --更新在线桌数 local clubId = tonumber(message.gid) local content = json.decode(message.content or "") if content then local baoJianId = tonumber(content.ruleid) local onlineroom = tonumber(content.onlineroom) local baoJian = self:getBaoJian(clubId,baoJianId) if baoJian then baoJian.onlineRoomNum = onlineroom end if self.clubList[clubId] then self.clubList[clubId].onlineRoomNum = onlineroom self:dispatchEvent({name = GAME_EVENT.CLUB_TABLE_NUM}) end end elseif msgType == ClubDefine.PUSH.message then --消息推送 local clubId = tonumber(message.gid) local newContent = message.newContent or {} if self.clubList[clubId] and newContent.unionhints then self.clubList[clubId].isUnionHints = tonumber(newContent.unionhints) == 1 self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_HITS}) else if self.clubList[clubId] then self.clubList[clubId].isHints = true self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE}) end end elseif msgType == ClubDefine.PUSH.invite then --邀请好友 local clubId = tonumber(message.gid) local content = json.decode(message.content or "") if content then self:dispatchEvent({name = GAME_EVENT.CLUB_INVITE, clubId = clubId, content = content}) end elseif msgType == ClubDefine.PUSH.dayingjiaset then local clubId = tonumber(message.gid) local content = message.content or {} if content then local clubList = app.club_php.clubList[tonumber(clubId)] if clubList then local ruleList = clubList.baoJians; for k,v in pairs(content) do if ruleList[tonumber(k)] then ruleList[tonumber(k)].playWinScore = v.play_win_threshold or 0 end end end end self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_PUSH}) elseif msgType == ClubDefine.PUSH.changeClubBg then local clubId = tonumber(message.gid) local content = message.content or {} local clubInfo = app.club_php.clubList[clubId]; if content.prop and clubInfo then if clubInfo.club_bgprop then clubInfo.club_bgprop = content.prop or clubInfo.club_bgprop or {} end end self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BG}) elseif msgType == ClubDefine.PUSH.cancelCopartner then local clubId = tonumber(message.gid) local content = message.content or {} local cancelCopartner = content.cancelCopartner if cancelCopartner and cancelCopartner.uid then self:dispatchEvent({name = GAME_EVENT.CLUB_CANCEL_COPARTNER_NOTICE,response = cancelCopartner}) end elseif msgType == ClubDefine.PUSH.gameActive then local clubId = tonumber(message.gid) local content = message.content or {} if clubId then self:requestClubHome(clubId,nil,nil,2) end elseif msgType == ClubDefine.PUSH.updateUnionMasterState then local clubId = tonumber(message.gid) local clubId = tonumber(message.gid) local viewType = toNumber(message.content.viewType) or ClubDefine.PlayListType.UNION_CLUB_LIST if message.content.type == 0 then --删除成员 local gidList = message.content.delGids if self.clubList[clubId] and gidList then for k,gid in pairs(gidList) do self.clubList[clubId].unionPlayerList[tonumber(gid)] = nil end self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST}) end elseif message.content.type == 1 then --新增成员 local groups = message.content.groups if groups then for k,v in pairs(groups) do self:updateClubUnionClubId(clubId,v,nil,viewType) end end self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST}) elseif message.content.type == 2 then --修改副盟属性更新 local groups = message.content.groups if groups then for k,v in pairs(groups) do self:updateClubUnionClubId(clubId,v,true,viewType) end end end self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST,type = viewType}) elseif msgType == ClubDefine.PUSH.updateUnionSlaveState then local clubId = tonumber(message.gid) local content = message.content or {} self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_SLAVE_UPDATE}) --status : {1正常, 2冻结, 0解除联盟关系, 3加入主盟,更新桌子} if content.status == 0 or content.status == 3 or content.status == 4 then self:requestClubHome(clubId) end elseif msgType == ClubDefine.PUSH.updateCestStatus then --刷新玩家CEST个人信息 local clubId = tonumber(message.gid) self:requestCestUserInfo(clubId) elseif msgType == ClubDefine.PUSH.updateCestSet then --刷新玩家CEST 三个场的设置 local clubId = tonumber(message.gid) if clubId then if app.club_php:getCestIsOpen(clubId) then self:requestCestGameInfo({clubId=clubId}) end end elseif msgType == ClubDefine.PUSH.updateCestManage then -- 刷新CEST管理界面 self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST}) elseif msgType == ClubDefine.PUSH.updateCestMinge then -- 刷新CEST用户参赛名额次 self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_REQUEST_MINGE_INFO}) elseif msgType == ClubDefine.PUSH.updateCestApplyMessage then -- 刷新CEST海选赛申请消息 self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_UPDATE_APPLY_LIST}) end end function ClubProtocolPhp:isNeedUpdateTable(clubId,ruleid) -- 如果不是当前激活的玩法的桌子数据,则丢弃不处理 local clubRuldId = self:getSelectBaoJianId() local clubLeftGame = self:getSelectGameId() local baoJian = self:getBaoJian(clubId,ruleid) local currentGameId = 0 if baoJian then currentGameId = baoJian.gameId end logD("clubLeftGame:",clubLeftGame) logD("clubRuldId:",clubRuldId) logD("currentGameId:",currentGameId) --0代表全部游戏or包间选项 if clubLeftGame ~= 0 and currentGameId ~= clubLeftGame or currentGameId == 0 then --非处于全部游戏状态,不同游戏禁止刷新 return false; end if clubLeftGame ~= 0 and clubRuldId ~= 0 and clubRuldId ~= tonumber(ruleid) then --非处于全部游戏且非全部包间场景,不同玩法禁止刷新 return false; end return true end --获取俱乐部列表 function ClubProtocolPhp:requestClubList(callback) local param = { version = "20180605" } self:post(Cmd.PHP_CLUB_LIST,param,function(response) --logD("ClubProtocolPhp:getClubList",table.tostring(response)) if response.code==200 then local result = response.result --被踢出茶馆时,(防止没有收到推送)检测删掉已经被踢出的茶馆的数据 if next(result) ~= nil then local tExitClub = {} for k,v in pairs(self.clubList) do for i,j in pairs(result) do if v.clubId == tonumber(j.gid) then tExitClub[v.clubId] = true end end end for k,v in pairs(self.clubList) do if not tExitClub[v.clubId] then self.clubList[k] = nil end end for k,v in pairs(result) do self:updateClub(v) self:updateClubSettings(v.gid,v.settings) end end if callback then callback() end self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) end end) end --获取俱乐部列表 function ClubProtocolPhp:requestAllClubList(callback,version) local param = { version = version or "20190617" } self:post(Cmd.PHP_CLUB_LIST,param,function(response) logD("ClubProtocolPhp:requestAllClubList",table.tostring(response)) if response.code==200 then local result = response.result --被踢出茶馆时,(防止没有收到推送)检测删掉已经被踢出的茶馆的数据 if next(result) ~= nil then --[[local tExitClub = {} for k,v in pairs(self.clubList) do for i,j in pairs(result) do if v.clubId == tonumber(j.gid) then tExitClub[v.clubId] = true end end end for k,v in pairs(self.clubList) do if not tExitClub[v.clubId] then self.clubList[k] = nil end end--]] self.clubListAll = {} for k,v in pairs(result) do self:updateClub(v,true) end end if callback then callback() end self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) end end) end function ClubProtocolPhp:getClubList() logD("getClubList 已经修改为 requestClubList") self:requestClubList() end function ClubProtocolPhp:getClubInfo(clubId) if self.clubList then return self.clubList[clubId] else return nil end end function ClubProtocolPhp:requestClub(clubId) local param = { gid = clubId, version = "20180605" } self:post(Cmd.PHP_CLUB_ONE_CLUB,param,function(response) logD("ClubProtocolPhp:requestClub",table.tostring(response)) if response.code==200 then local result = response.result if next(result) ~= nil then self:updateClub(result) self:updateClubSettings(result.gid,result.settings) end self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) end end) end function ClubProtocolPhp:clubInviteSameTable() local GameRoomId = getGameRoomId() log("ClubProtocolPhp:clubInviteSameTable() GameRoomId = ", GameRoomId) local BroadcastCode = 10050; local Content = {}; Content.roomid = GameRoomId Content.gname = self.clubList[app.club_php.clubID].clubName local gclubInfo = self.clubList[app.club_php.clubID] local myUserInfo = json.decode(app.user.userInfo) local userInfo = { uid = app.user.loginInfo.uid, nick = myUserInfo.nickname, icon = myUserInfo.headimgurl, baojianid = tonumber(getAgainGameBaoJianId()), } local uids = "" local againbol,wanfa,uidList = getIsAgainGamebol() if uidList then for k,v in pairs(uidList) do uids = uids..v if k ~= #uidList then uids = uids.."," end end end Content.userInfo = userInfo self.ruleStr = wanfa setIsAgainGamebol(false,"") setMyGameCreateStatus(false) setAgainGameBaoJianId(-1) Content.gamerule = self.ruleStr local BroadcastContent = json.encode(Content) log("ClubProtocolPhp:clubInviteSameTable() BroadcastContent = ", BroadcastContent) app.club_php:requestBroadcast(app.club_php.clubID, uids, BroadcastCode, BroadcastContent) end --请求茶馆玩法 function ClubProtocolPhp:requestGameRule(clubId) local param = { gid = clubId } self:post(Cmd.PHP_CLUB_GET_GAME_RULE,param,function(response) logD("ClubProtocolPhp:requestGameRule",table.tostring(response)) --返回的status:1正常2禁止选择3隐藏 if response.code==200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_GAME_RULE, result = result}) end end) end --设置玩法 function ClubProtocolPhp:requestChangeRule(clubId,baoJianId,gameId,gameNum,gameRule,isDelete,arena,title) local param = { gid = clubId, ruleid = baoJianId, game_id = gameId, game_num = gameNum, gamerule = gameRule, is_delete = isDelete, arena = arena, title = title or "", version = "20190822" } app.waitDialogManager:showWaitNetworkDialog("正在保存玩法...") self:post(Cmd.PHP_CLUB_CHANGE_RULE,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestChangeRule",table.tostring(response)) if response.code==200 then if isDelete == 1 then showTooltip("玩法删除成功") else showTooltip("玩法保存成功") end --save local club = self.clubList[clubId] if club then local baojian = self:getBaoJian(clubId,gameId,baoJianId) if baojian then baojian.arena = arena end end --self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_RULE}) else self:showError(Cmd.PHP_CLUB_CHANGE_RULE,response) end end) end --更新包间设置 function ClubProtocolPhp:requestRuleSet(clubId,baoJianId,tp,value) local param = { gid = clubId, ruleid = baoJianId, type = tp, --1:切换包间(任意成员) $value = 1, 2更新玩法名(管理员/创始人), $value = title type3包间信息更新 4 设置包间的比赛场参数你看看 value = value, } -- app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_RULE_SET,param,function(response) -- app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestRuleSet",table.tostring(response)) if response.code==200 then if tp==1 then --切换包间 if app.club_php:getCestIsOpen(clubId) then showTooltip("切换赛事成功") else showTooltip("切换包间成功") end self:updateClubSettingsByBaoJian(clubId,baoJianId) self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BAO_JIAN}) elseif tp == 2 then self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BAO_JIAN_NAME}) elseif tp == 3 then showTooltip("设置成功") self:dispatchEvent({name = GAME_EVENT.CLUB_SET}) elseif tp == 4 then showTooltip("设置成功") local club = self.clubList[clubId] if club then local baojian = self:getBaoJian(clubId,baoJianId) if baojian then local valueData = json.decode(value) baojian.arena = json.encode(valueData[tostring(baoJianId)]) end end self:dispatchEvent({name = GAME_EVENT.CLUB_SET_MATCH}) end else self:showError(Cmd.PHP_CLUB_RULE_SET,response) end end) end --批量更新包间设置 function ClubProtocolPhp:requestSetAllBaoJian(clubId,tp,value) local param = { gid = clubId, type = tp, --5更新包间样式 values = value, } self:post(Cmd.PHP_CLUB_BAOJIAN_SET_STYLE,param,function(response) logD("ClubProtocolPhp:requestSetAllBaoJian",table.tostring(response)) if response.code == 200 then if tp == 5 then --切换包间 showTooltip("设置成功") --self:dispatchEvent({name = GAME_EVENT.CLUB_CHANGE_BAO_JIAN}) end else self:showError(Cmd.PHP_CLUB_BAOJIAN_SET_STYLE,response) end end) end --创建茶馆 function ClubProtocolPhp:requestCreateClub(clubName) local param = { groupname = clubName, version = app.config.ModuleConfig.IsSupportRankMatch and "20191101" or nil } app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_CREATE,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestCreateClub",table.tostring(response)) if response.code==200 then showTooltip(PLN.CLUB_CEST_CREATE_SUCCESS) local result = response.result self:updateClub(result) self:updateClubSettings(result.gid,result.settings) self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) self:dispatchEvent({name = GAME_EVENT.CLUB_CREATE_SUCCESS, data = result}) if cc.Application:getInstance():getTargetPlatform() == 0 then cc.UserDefault:getInstance():setIntegerForKey("LastTestClubID",result.gid) cc.UserDefault:getInstance():flush() end else response.error = string.gsub(response.error,"茶馆", "赛事") response.error = string.gsub(response.error,"亲友圈", "赛事") self:showError(Cmd.PHP_CLUB_CREATE,response) end end) end --加入茶馆 function ClubProtocolPhp:requestJoinClub(clubId,playerName,headImgUrl) local param = { gid = clubId, nick = playerName, icon = headImgUrl, } self:post(Cmd.PHP_CLUB_JOIN,param,function(response) logD("ClubProtocolPhp:requestJoinClub",table.tostring(response)) self:dispatchEvent({name = GAME_EVENT.CLUB_JOIN , errCode = response.code}) end) end --退出茶馆 function ClubProtocolPhp:requestExitClub(clubId) local param = { gid = clubId, } self:post(Cmd.PHP_CLUB_EXIT,param,function(response) logD("ClubProtocolPhp:requestExitClub",table.tostring(response)) if response.code == 200 then -- 先帮PHP处理 if app.club_php:getCestIsOpen(clubId) then if response.result.content then response.result.content = string.gsub(response.result.content, "亲友圈", "赛事") end end if response.result and response.result.is_exitapply == 1 then if response.result.content then showTooltip(tostring(response.result.content)) else showTooltip(tostring(response.error)) end else self.clubList[clubId] = nil self:dispatchEvent({name = GAME_EVENT.CLUB_JIE_SAN, clubId = clubId}) self:dispatchEvent({name = GAME_EVENT.CLUB_LIST}) end else -- 先帮PHP处理 if app.club_php:getCestIsOpen(clubId) then if response.code then if tostring(response.code) == "1011" then response.error = "请先结束本轮比赛后再退出!" end end if response.error then response.error = string.gsub(response.error, "成员", "选手") response.error = string.gsub(response.error, "排名分", "成绩") end end self:showError(Cmd.PHP_CLUB_EXIT,response) end end) end --设置茶馆 function ClubProtocolPhp:requestSetClub(clubId,setType,value) local param = { gid = clubId, type = setType, value = value, } --1 => 状态操作茶馆(管理员) $value 1正常2冻结0解散, --2 => 加入设置 (管理员) $value 1需要申请,0无需申请, --3 => 修改昵称(管理员) $value 新群名 --4 => 隐私修改 $value 1开启隐私0默认关闭 --6 => 微信分享is_wxshare $value 1禁止微信分享, 0开启; --7 => 房间模式修改room_mode$value 1多玩法模式, 0包间模式; --8 => 大赢家特殊统计阈值修改修改play_win_threshold $value 给最后确认的数值(没有广播) self:post(Cmd.PHP_CLUB_SET,param,function(response) logD("ClubProtocolPhp:requestSetClub",table.tostring(response)) if response.code==200 then --修改茶馆申请参数 if setType==GAME_CLUB_SET_STATE.Join_set then local club = self.clubList[clubId] if club then club.isApply = value==1 end elseif setType==GAME_CLUB_SET_STATE.Set_win_socre then local club = self.clubList[clubId] if club then club.playWinScore = value end elseif setType==GAME_CLUB_SET_STATE.Quit_set then local club = self.clubList[clubId] if club then club.isExitApply = value==1 end end showTooltip("设置成功") -- local result = response.result -- self:updateClub(result) self:dispatchEvent({name = GAME_EVENT.CLUB_SET , setType = setType, value = value}) else -- 先帮PHP处理 if app.club_php:getCestIsOpen(clubId) then if response.code then if tostring(response.code) == "1010" then response.error = "解散失败,名下选手本轮成绩未上报,请结束本轮比赛后再解散!" end end end self:showError(Cmd.PHP_CLUB_SET,response) end end) end --多设置茶馆 function ClubProtocolPhp:requestSetClubNew(clubId,jsonData,callback) local tt = { gid = clubId, type = jsonData.type or 1, } local params = jsonData tt.params = json.encode(params) self:post(Cmd.PHP_CLUB_SET_MORE,tt,function(response) logD("ClubProtocolPhp:requestSetClubNew",table.tostring(response)) if response.code==200 then --type 0的情况,服务器不做通知。 if tt.type == 0 then local clubInfo = self.clubList[clubId] if clubInfo then local cliext = clubInfo.groupext and clubInfo.groupext.cliext if cliext then cliext.readUnionGuide = 1 end end else --修改茶馆申请参数 showTooltip("设置成功") self:dispatchEvent({name = GAME_EVENT.CLUB_SET}) end if self:getCestIsOpen(clubId) then self:setCestFirst(clubId, false) if jsonData.cestext then -- 修改成功后,更新海选赛三个场的积分和轮数信息 local cestext = json.decode(jsonData.cestext) local club = self.clubCestInfo -- club.one_gamenum =cestext.one_gamenum or self.clubCestInfo.one_gamenum or 0 -- club.one_point =cestext.one_point or self.clubCestInfo.one_point or 0 -- club.two_gamenum =cestext.two_gamenum or self.clubCestInfo.two_gamenum or 0 -- club.two_point =cestext.two_point or self.clubCestInfo.two_point or 0 -- club.three_gamenum =cestext.three_gamenum or self.clubCestInfo.three_gamenum or 0 -- club.three_point =cestext.three_point or self.clubCestInfo.three_point or 0 local clubInfo = self:getClubInfo(clubId) if clubInfo then if clubInfo.groupext then if clubInfo.groupext.cestext then if clubInfo.groupext.cestext.one_gamenum then clubInfo.groupext.cestext.one_gamenum = cestext.one_gamenum or self.clubCestInfo.one_gamenum or 0 clubInfo.groupext.cestext.one_point =cestext.one_point or self.clubCestInfo.one_point or 0 clubInfo.groupext.cestext.two_gamenum =cestext.two_gamenum or self.clubCestInfo.two_gamenum or 0 clubInfo.groupext.cestext.two_point =cestext.two_point or self.clubCestInfo.two_point or 0 clubInfo.groupext.cestext.three_gamenum =cestext.three_gamenum or self.clubCestInfo.three_gamenum or 0 clubInfo.groupext.cestext.three_point =cestext.three_point or self.clubCestInfo.three_point or 0 clubInfo.groupext.cestext.mid_gamenum =cestext.mid_gamenum or self.clubCestInfo.mid_gamenum or 0 clubInfo.groupext.cestext.mid_point =cestext.mid_point or self.clubCestInfo.mid_point or 0 end end end end self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GAMEINFO}) end end if callback then callback() end else if jsonData.clientSwitch == 1 then local dailis = app.php.daili[0] or app.php.daili[-1] or {} local kefu = "" local index = 1 local max = 2 for k,v in pairs(dailis) do if index < max then kefu = kefu..v.."," elseif index == max then if v ~= "" then kefu = kefu..v end end index = index + 1 end self:dispatchEvent({name = GAME_EVENT.CLUB_SET_COPARTNER_ONE_FAILE , content = "",title = app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_SET_MATCH_SWITCH_TIP or PLN.CLUB_SET_MATCH_SWITCH_TIP}) else self:showError(Cmd.PHP_CLUB_SET,response) end end end) end --请求亲友圈消息 function ClubProtocolPhp:requestMsg(clubId) local param = { gid = clubId, } self:post(Cmd.PHP_CLUB_MANAGER_MSG,param,function(response) logD("ClubProtocolPhp:requestMsg",table.tostring(response)) if response.code==200 then local result = response.result self:updateClubMessages(clubId,result.lists) self:updateClubHints(clubId,result) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CLUB_MESSAGE}) --茶馆消息tag为1 else self:showError(Cmd.PHP_CLUB_MANAGER_MSG,response) end end) end --排名赛申请 function ClubProtocolPhp:requestMatchMessageList(clubId) local param = { gid = clubId, } app.waitDialogManager:showWaitNetworkDialog("正在请求..."); self:post(Cmd.PHP_CLUB_WARNUM_APPLY_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog(); logD("ClubProtocolPhp:requestMatchMessageList",table.tostring(response)) if response.code==200 then local result = response.result self:updateClubMatchMessages(clubId,result.lists) self:updateClubHints(clubId,result) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.ALL_PEOPLE_MATCH_APPLY}) --茶馆消息tag为1 else app.waitDialogManager:closeWaitNetworkDialog(); self:showError(Cmd.PHP_CLUB_WARNUM_APPLY_LIST,response) end end) end --请求加入申请消息 function ClubProtocolPhp:requestApplyMsg(clubId) local param = { version = "1", gid = clubId, type = 0, } self:post(Cmd.PHP_CLUB_APPLY_MSG,param,function(response) logD("ClubProtocolPhp:requestApplyMsg",table.tostring(response)) if response.code==200 then local result = response.result self:updateClubApplyMessages(clubId,result.lists,1) self:updateClubHints(clubId,result) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --申请消息 self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --合伙人申请消息 else self:showError(Cmd.PHP_CLUB_APPLY_MSG,response) end end) end --请求退出申请消息 function ClubProtocolPhp:requestExitApplyMsg(clubId) local param = { gid = clubId, } self:post(Cmd.PHP_CLUB_EXIT_APPLY_MSG,param,function(response) logD("ClubProtocolPhp:requestExitApplyMsg",table.tostring(response)) if response.code==200 then local result = response.result self:updateClubApplyMessages(clubId,result.lists,2) self:updateClubHints(clubId,result) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --退出申请消息 self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --退出合伙人申请消息 else self:showError(Cmd.PHP_CLUB_APPLY_MSG,response) end end) end --处理申请 function ClubProtocolPhp:requestChangeApplyStatus(clubId,uid,status,index) local param = { gid = clubId, applyUid = uid, ops = status, --1同意,2拒绝, 3全部同意(无需applyUid) } app.waitDialogManager:showWaitNetworkDialog(); self:post(Cmd.PHP_CLUB_CHANGE_APPLY_STATUS,param,function(response) app.waitDialogManager:closeWaitNetworkDialog(); logD("ClubProtocolPhp:requestChangeApplyStatus",table.tostring(response)) if response.code==200 then --修改状态 local userInfo = json.decode(app.user.userInfo); self:updateClubApplyMessageStatus(clubId,index,status,app.user.loginInfo.uid,userInfo.nickname) --检测处理完成后设置红点不显示 local isApplyHints = false for k,v in pairs(self.clubList[clubId].applyMessages) do if v.status==0 then isApplyHints = true end end if not isApplyHints then self:requestSetHints(clubId,"applyhints") end --检测处理完成后设置合伙人红点不显示 local isCoApplyHints = false for k,v in pairs(self.clubList[clubId].coapplyMessages) do if v.status==0 then isCoApplyHints = true end end if not isCoApplyHints then self:requestSetHints(clubId,"coapplyhints") end self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --申请消息 self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --合伙人申请消息 self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED}) else self:showError(Cmd.PHP_CLUB_CHANGE_APPLY_STATUS,response) end end) end function ClubProtocolPhp:requestChangeExitApplyStatus(clubId, uid, status, index) local param = { gid = clubId, applyUid = uid, uid = app.user.loginInfo.uid, ops = status, } app.waitDialogManager:showWaitNetworkDialog(); self:post(Cmd.PHP_CLUB_CHANGE_EXIT_APPLY_STATUS,param,function(response) app.waitDialogManager:closeWaitNetworkDialog(); logD("ClubProtocolPhp:requestChangeExitApplyStatus",table.tostring(response)) if response.code==200 then --修改状态 self:updateClubApplyMessageStatus(clubId,index,status) -- if index and self.clubList[clubId] and self.clubList[clubId].applyMessages[index] then -- self.clubList[clubId].applyMessages[index].status = status -- end --检测处理完成后设置红点不显示 local isApplyHints = false for k,v in pairs(self.clubList[clubId].applyMessages) do if v.status==0 then isApplyHints = true end end if not isApplyHints then self:requestSetHints(clubId,"exitapplyhints") end --检测处理完成后设置合伙人红点不显示 local isCoApplyHints = false for k,v in pairs(self.clubList[clubId].coapplyMessages) do if v.status==0 then isCoApplyHints = true end end if not isCoApplyHints then self:requestSetHints(clubId,"coexitapplyhints") end self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.PLAYER_APPLY}) --退出申请消息 self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.TEAMER_APPLY}) --退出合伙人申请消息 self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED}) else self:showError(Cmd.PHP_CLUB_CHANGE_APPLY_STATUS,response) end end); end function ClubProtocolPhp:requestMatchMessageApplyStatus(clubId, id, status,viewType) local param = { gid = clubId, id = id, --申请id ops = status, viewType = viewType, } app.waitDialogManager:showWaitNetworkDialog(); self:post(Cmd.PHP_CLUB_WARNUM_APPLY_STATUS,param,function(response) app.waitDialogManager:closeWaitNetworkDialog(); logD("ClubProtocolPhp:requestMatchMessageApplyStatus",table.tostring(response)) if response.code==200 then --修改状态 self:updateClubMatchMessageApplyStatus(clubId,id,status) --检测处理完成后设置红点不显示 local isApplyHints = false for k,v in pairs(self.clubList[clubId].matchMessages) do if v.status==0 then isApplyHints = true end end --local player = self:getPlayer(clubId,app.user.loginInfo.uid) if not isApplyHints and self.clubList[clubId].role ~= ClubDefine.Job.LevelOneCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelTwoCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelThreeCopartner then self:requestSetHints(clubId,"warnumhints") end self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.ALL_PEOPLE_MATCH_APPLY}) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED}) else app.waitDialogManager:closeWaitNetworkDialog(); self:showError(Cmd.PHP_CLUB_WARNUM_APPLY_STATUS,response) end end); end --请求奖励列表 function ClubProtocolPhp:requestAwardList(clubId) local param = { gid = clubId, } self:post(Cmd.PHP_CLUB_AWARD_LIST,param,function(response) logD("ClubProtocolPhp:requestAwardList",table.tostring(response)) if response.code==200 then local result = response.result self:updateClubAwardMessages(clubId,result.list) self:updateClubHints(clubId,result) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.AWARD_APPLY}) --奖励消息tag为2 else self:showError(Cmd.PHP_CLUB_AWARD_LIST,response) end end) end function ClubProtocolPhp:updateClubHints(clubId,result) --loghints:亲友圈消息, awardhints:奖励消息, applyhints:申请消息, --scorehints:疲劳值消息, fucardhints:福卡消息, exitapplyhints:退出申请 --warnumhints:排名赛申请红点 coapplyhints:合伙人相关的入群申请 coexitapplyhints:合伙人相关的退群申请 --奖励消息红点0:无,1:有 if self.clubList[clubId] and result then if result.loghints then self.clubList[clubId].isLogHints = tonumber(result.loghints)==1 end if result.awardhints then self.clubList[clubId].isAwardHints = tonumber(result.awardhints)==1 end if result.applyhints then self.clubList[clubId].isApplyHints = tonumber(result.applyhints)==1 end if result.scorehints then self.clubList[clubId].isScorehints = tonumber(result.scorehints)==1 end if result.fucardhints then self.clubList[clubId].isFucardhints = tonumber(result.fucardhints)==1 end if result.exitapplyhints then self.clubList[clubId].isExitApplyHints = tonumber(result.exitapplyhints)==1 end if result.warnumhints then self.clubList[clubId].isWarnumhints = tonumber(result.warnumhints)==1 end if result.coapplyhints then self.clubList[clubId].isCoApplyHints = tonumber(result.coapplyhints)==1 end if result.coexitapplyhints then self.clubList[clubId].isCoexitapplyhints = tonumber(result.coexitapplyhints)==1 end --是否显示红点 self.clubList[clubId].isHints = self.clubList[clubId].isLogHints or self.clubList[clubId].isAwardHints or self.clubList[clubId].isApplyHints or self.clubList[clubId].isScorehints or self.clubList[clubId].isFucardhints or self.clubList[clubId].isExitApplyHints or self.clubList[clubId].isWarnumhints or self.clubList[clubId].isCoApplyHints or self.clubList[clubId].isCoexitapplyhints end end --请求成员列表 --看了很多参数传了很多Nil,现在统一第一个为Json,不然参数一堆过来,传的时候还要数第几个,对于子游戏做了兼容 function ClubProtocolPhp:requestPlayerList(clubId,orderBy,sort,day,status) if type(clubId) == "number" then self.openData = { clubId = clubId, orderBy = orderBy or "role", sort = sort or "desc", day = day or 0, status = status or 0, } else self.openData = clubId end local param = { gid = self.openData.clubId, orderby = self.openData.orderBy or "role", --排序字段:play_number, play_win_number, role, online, 默认role desc sort = self.openData.sort or "desc", --排序类型asc desc lastday = self.openData.day or 0, --day时间标签,默认传0当天1昨天2前天3大前天 type = self.openData.status or 0, -- 0默认成员数据,1在线成员数据 lastweek = self.openData.day==3 and 1 or -1, --上周 lastmonth = self.openData.day==4 and 1 or -1, --上月 viewType = self.openData.viewType or 0, --要刷新那个界面,由于成员列表和比赛成员,记录都用一个接口,当不同消息来的时候,避免界面刷新错乱加这个控制 muid = self.openData.muid or 0, --创始人查看一级合伙人的下属成员时muid = 一级合伙人uid suid = self.openData.suid or "", --搜索的ID version = "20190227", } self:post(Cmd.PHP_CLUB_PLAYER_LIST,param,function(response) if isWin32Platform() then logD("ClubProtocolPhp:requestPlayerList",table.tostring(response)) end if response.code==200 then local result = response.result if self.clubList[param.gid] then if param.viewType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_MEMBER or param.viewType == ClubDefine.PlayListType.MATCH_LV_2_COPARTNER_RECORD then self.clubList[param.gid].playersLevelTwo = {} else self.clubList[param.gid].playersLevelOne = {} self.clubList[param.gid].playersLevelTwo = {} end self.clubList[param.gid].playerNum = tonumber(result.gnum) self.clubList[param.gid].isHidePlay = tonumber(result.is_hideplay) == 1 self.clubList[param.gid].onlinePlayerNum = tonumber(result.onlinemember) self.clubList[param.gid].totalPlayerNum = tonumber(result.count)--总人数根据角色变化的总人数,老的gnum不用 --为了显示大赢家信息加上请求的时间 self.clubList[param.gid].lastday = param.lastday end if param.suid ~= "" then self.clubList[param.gid].players = {} self:updateClubPlayers(param.gid,result.list,param.viewType,param.type) self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_SEARCH,result = result,type = param.viewType}) else self:updateClubPlayers(param.gid,result.list,param.viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_LIST,type = param.viewType,clubId = param.gid}) end else self:showError(Cmd.PHP_CLUB_PLAYER_LIST,response) end end) end --请求邀请的成员列表 function ClubProtocolPhp:requestInvitePlayerList(clubId,orderBy,sort,day,status) local param = { gid = clubId, orderby = orderBy or "role", --排序字段:play_number, play_win_number, role, online, 默认role desc sort = sort or "desc", --排序类型asc desc lastday = day or 0, --day时间标签,默认传0当天1昨天2前天3大前天 type = status or 0, -- 0默认成员数据,1在线成员数据 version = "180605", } self:post(Cmd.PHP_CLUB_PLAYER_LIST,param,function(response) if isWin32Platform() then logD("ClubProtocolPhp:requestInvitePlayerList",table.tostring(response)) end if response.code==200 then local result = response.result if self.clubList[clubId] then self.clubList[clubId].playerNum = tonumber(result.gnum) self.clubList[clubId].isHidePlay = tonumber(result.is_hideplay) == 1 end local players = {} if result.list then for k,v in pairs(result.list) do local player = {} player.uid = tonumber(v.uid) player.name = v.nick player.sex = v.sex --玩家性别:0未知1男2女 player.strHeadUrl = v.icon --玩家头像地址 player.desc = v.desc --备注 player.playNum = v.play_number --局数 player.lastPlayNum = v.last_play_number --昨日局数 player.playWinNum = v.play_win_number --大赢家次数 player.lastPlayWinNum = v.last_play_win_number --昨日大赢家次数 player.online = v.online --1在线0离线 player.role = tonumber(v.role) --1成员2管理员3创建人 player.status = v.status --1正常0黑名单成员 player.agent = v.agent --1是代理0不是代理 player.totalScore = v.total_score --输赢积分 player.lastTotalScore = v.last_total_score --昨日输赢积分 if v.isplay then player.isPlay = v.isplay == 1 --是否在游戏中(1:游戏中) end players[player.uid] = player end end self:dispatchEvent({name = GAME_EVENT.CLUB_INVITE_PLAYER_LIST , players = players}) else self:showError(Cmd.PHP_CLUB_PLAYER_LIST,response) end end) end --设置成员 --[[ $type 1 加入管理员, 无需$value $type 2 解除管理员, 无需$value $type 3 加入黑名单, 无需$value $type 4 解除黑名单, 无需$value $type 5 备注昵称 $value = '备注的信息' $type 6 加入合伙人, 无需$value $type 7 解除普通合伙人, 无需$value $type 8 解除普通合伙人对成员的绑定, 无需$value $type 9 删除比赛场合伙人, 管理员调用时, 只能删除一级; 一级调用时, 只能删除二级 $type 10 加入比赛场合伙人, 管理员调用时, 只能增加一级; 一级调用时, 只能增加二级 $type 11 设置下级比赛合伙人分成比例 $type 12 指定合伙人和其下属冻结 $type 13 指定合伙人和其下属解冻 ]] function ClubProtocolPhp:requestSetClubPlayer(clubId,uid,memberuid,opType,value,callback,viewType) local param = { gid = clubId, uid = uid, --操作ID memberuid = memberuid, --被操作ID type = opType, value = value, viewType = viewType or 0, } self:post(Cmd.PHP_CLUB_PLAYER_SET,param,function(response) logD("ClubProtocolPhp:requestSetClubPlayer",table.tostring(response)) if response.code==200 then --TODO 暂时通过推送数据修改本地数据 if callback then callback() end if response.error and response.error ~= "" then showTooltip(response.error) end else if opType == 10 then self:dispatchEvent({name = GAME_EVENT.CLUB_SET_COPARTNER_ONE_FAILE , content = "",title = (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_SET_COPRATNER_FAIL_TIP or PLN.CLUB_SET_COPRATNER_FAIL_TIP)}) else self:showError(Cmd.PHP_CLUB_PLAYER_SET,response) end end end) end --排名赛新接口 --设置成员 --[[ $type 1 加入管理员, 无需$value $type 2 解除管理员, 无需$value $type 3 加入黑名单, 无需$value $type 4 解除黑名单, 无需$value $type 5 备注昵称 $value = '备注的信息' $type 6 加入合伙人, 无需$value $type 7 解除普通合伙人, 无需$value $type 8 解除普通合伙人对成员的绑定, 无需$value $type 9 删除比赛场合伙人, 管理员调用时, 只能删除一级; 一级调用时, 只能删除二级 $type 10 加入比赛场合伙人, 管理员调用时, 只能增加一级; 一级调用时, 只能增加二级 $type 11 设置下级比赛合伙人分成比例 $type 12 指定合伙人和其下属冻结 $type 13 指定合伙人和其下属解冻 ]] function ClubProtocolPhp:requestSetPlayer(clubId,uid,memberuid,opType,value,callback,viewType) local param = { gid = clubId, uid = uid, --操作ID memberuid = memberuid, --被操作ID type = opType, value = value, viewType = viewType or 0, } self:post(Cmd.PHP_CLUB_WARMEMBERSTATUS,param,function(response) logD("ClubProtocolPhp:requestSetPlayer",table.tostring(response)) if response.code==200 then --TODO 暂时通过推送数据修改本地数据 if callback then callback() end self:showError(Cmd.PHP_CLUB_WARMEMBERSTATUS,response,true) else if opType == 10 and response.code == 1210 then self:dispatchEvent({name = GAME_EVENT.CLUB_SET_COPARTNER_ONE_FAILE , content = "",title = (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_SET_COPRATNER_FAIL_TIP or PLN.CLUB_SET_COPRATNER_FAIL_TIP)}) else self:showError(Cmd.PHP_CLUB_WARMEMBERSTATUS,response) end end end) end --删除成员 function ClubProtocolPhp:requestRemovePlayer(clubId,uid,viewType) local param = { gid = clubId, kickuid = uid, viewType = viewType or 0, } self:post(Cmd.PHP_CLUB_REMOVE_PLAYER,param,function(response) logD("ClubProtocolPhp:requestRemovePlayer",table.tostring(response)) if response.code==200 then --TODO 暂时通过推送数据修改本地数据 if response.result.content then showTooltip(tostring(response.result.content)) end else -- 先帮PHP处理 if app.club_php:getCestIsOpen(clubId) then if response.code then if tostring(response.code) == "1011" then response.error = "请先结束本轮比赛后再退出!" end end end self:showError(Cmd.PHP_CLUB_REMOVE_PLAYER,response) end end) end --添加成员 function ClubProtocolPhp:requestAddPlayer(uid,clubId,viewType) local param = { gid = clubId, addUid = uid, viewType = viewType, } app.waitDialogManager:showWaitNetworkDialog(); self:post(Cmd.PHP_CLUB_ADD_PLAYER,param,function(response) logD("ClubProtocolPhp:requestAddPlayer",table.tostring(response)) app.waitDialogManager:closeWaitNetworkDialog(); if response.code==200 then if response.result.content then showTooltip(string.format(response.result.content)) else showTooltip("添加成员成功") end --TODO 暂时通过推送数据修改本地数据 self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_ADD}) else self:showError(Cmd.PHP_CLUB_ADD_PLAYER,response) end end) end --导入亲友圈前拉取数据 function ClubProtocolPhp:requestImportPlayerList(clubId,importClubId) local param = { gid = clubId, --被导入俱乐部ID getgid = importClubId, -- 指定拉取成员的群 viewType = 0 } app.waitDialogManager:showWaitNetworkDialog(); self:post(Cmd.PHP_CLUB_IMPORT_MEMBER,param,function(response) app.waitDialogManager:closeWaitNetworkDialog(); if isWin32Platform() then logD("ClubProtocolPhp:requestImportPlayerList",table.tostring(response)) end if response.code==200 then --self.clubList[param.gid].players = {} local result = response.result.list --self:updateClubPlayers(param.gid,result.list,param.viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_IMPORT_MBMBER,response = result}) else self:showError(Cmd.PHP_CLUB_IMPORT_MEMBER,response) end end) end --导入成员 function ClubProtocolPhp:requestImportPlayer(clubId,importClubId,memberuid) local param ={} if memberuid then param = { gid = clubId, getgid = importClubId, getmuid = memberuid, --被操作ID,"," split } else param = { gid = clubId, getgid = importClubId, } end app.waitDialogManager:showWaitNetworkDialog(); self:post(Cmd.PHP_CLUB_IMPORT_PLAYER,param,function(response) app.waitDialogManager:closeWaitNetworkDialog(); logD("ClubProtocolPhp:requestImportPlayer",table.tostring(response)) if response.code==200 then --TODO 暂时通过推送数据修改本地数据 if app.club_php:getCestIsOpen(clubId) then showPHPSuccessResult("导入选手成功") else showPHPSuccessResult("导入成员成功") end else self:showError(Cmd.PHP_CLUB_IMPORT_PLAYER,response) end end) end --获取禁止同桌列表 function ClubProtocolPhp:requestBanList(clubId,uid,viewType,isNew) local param = { gid = clubId, muid = uid, viewType = viewType or 0, isNew = isNew, } self:post(Cmd.PHP_CLUB_GET_JZ_SAME_TABLE,param,function(response) logD("ClubProtocolPhp:requestBanList",table.tostring(response)) if response.code==200 then local banList = {} local result = response.result if result.notdeskmate=="" then else if type(result.notdeskmate) == 'string' then local list = string.split(result.notdeskmate,",") for i,v in pairs(list) do table.insert(banList,tonumber(v)) end else for k,v in pairs(result.notdeskmate) do table.insert(banList,v) end end end self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_LIST , uid = uid , banList = banList,viewType = viewType}) else self:showError(Cmd.PHP_CLUB_GET_JZ_SAME_TABLE,response) end end) end --设置禁止同桌 function ClubProtocolPhp:requestSetNotDest(clubId,uid,banList) local strJzList = "" for i,v in pairs(banList) do strJzList = strJzList..v.."," end strJzList = string.sub(strJzList, 1, -2) local param = { gid = clubId, muid = uid, uids = strJzList } self:post(Cmd.PHP_CLUB_SET_JZ_SAME_TABLE,param,function(response) logD("ClubProtocolPhp:requestSetNotDest",table.tostring(response)) if response.code==200 then local result = response.result --设置禁止同桌成功 local addPlayerList = {} local delPlayerList = {} if type(result.addUids) == 'table' then --local list = string.split(result.notdeskmate,",") for i,v in pairs(result.addUids) do table.insert(addPlayerList,v) end end if type(result.cancelUids) == 'table' then for i,v in pairs(result.cancelUids) do table.insert(delPlayerList,v) end end showTooltip("设置成功") self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_SET,clubId = clubId,uid = uid,addPlayerList = addPlayerList,delPlayerList=delPlayerList}) else self:showError(Cmd.PHP_CLUB_SET_JZ_SAME_TABLE,response) end end) end --请求茶馆更新公告接口 function ClubProtocolPhp:requestUpdateNotice(clubId,notice) local param = { gid = clubId, notice = notice, } self:post(Cmd.PHP_CLUB_UPDATE_NOTICE,param,function(response) logD("ClubProtocolPhp:requestUpdateNotice",table.tostring(response)) if response.code==200 then --TODO 暂时通过推送数据修改本地数据 else self:showError(Cmd.PHP_CLUB_UPDATE_NOTICE,response) end end) end --茶馆官方活动 function ClubProtocolPhp:requestClubOfficialActivity(clubId) local param = { gid = clubId } app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_OFFICIAL_ACTIVITY,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestClubOfficialActivity",table.tostring(response)) if response.code==200 then local result = response.result local activitys = {} for k,v in pairsByKeys(result) do local activity = {}; activity.type = v.type; --活动ID activity.app = v.app; -- activity.tname = v.tname; --活动标题 activity.desc = v.desc; --活动描述 activity.img = v.img; --活动图 activitys[v.type] = activity end self:dispatchEvent({name = GAME_EVENT.CLUB_ACTIVITY_LIST, activitys = activitys}) elseif response.code==1049 then showConfirmDialog("精彩活动,敬请期待!") else self:showError(Cmd.PHP_CLUB_OFFICIAL_ACTIVITY,response) end end) end --获取已设置的禁止同桌玩家列表 function ClubProtocolPhp:requestForbidList(clubId,page,suid) local param = { gid = clubId, page = page or 0, suid = suid or 0, } app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_GET_FORBID_SAME_TABLE_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if isWin32Platform() then logD("ClubProtocolPhp:requestForbidList",table.tostring(response)) end if response.code == 200 then local result = response.result local playerList = {} if result.lists and table.nums(result.lists) > 0 then for uidK,uidV in pairs(result.lists) do local list = string.split(uidV,",") table.insert(playerList,list) end end self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_ALL_LIST,playerID = (result.lists == "" and {} or result.lists)}) else self:showError(Cmd.PHP_CLUB_GET_FORBID_SAME_TABLE_LIST,response) end end) end --禁止同队,战队列表 function ClubProtocolPhp:requestNotdeskteam(clubId,page,suid, uid) local param = { gid = clubId, page = page or 0, suid = suid or 0, uid = uid or 0, app = getAppId(), } app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_TABLE_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if isWin32Platform() then logD("ClubProtocolPhp:requestNotdeskteam",table.tostring(response)) end if response.code == 200 then -- local result = response.result local result = response local playerList = {} if result.list and table.nums(result.list) > 0 then for uidK,uidV in pairs(result.list) do local list = string.split(uidV,",") table.insert(playerList,list) end end -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_TABLE_LIST,playerID = (result.list == "" and {} or result.list)}) -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_TABLE_LIST, playerID = (result.list == "" and {} or result.list)}) self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_TABLE_LIST, result = result}) else self:showError(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_TABLE_LIST,response) end end) end --禁止同队,已经禁止战队 function ClubProtocolPhp:requestNotIndeskteam(clubId,page, uid) local param = { gid = clubId, page = page or 0, uid = uid or 0, app = getAppId(), } app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_JZ_TABLE_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if isWin32Platform() then logD("ClubProtocolPhp:requestNotIndeskteam",table.tostring(response)) end if response.code == 200 then -- local result = response.result local result = response -- local playerList = {} -- if result.list and table.nums(result.list) > 0 then -- for uidK,uidV in pairs(result.list) do -- local list = string.split(uidV,",") -- table.insert(playerList,list) -- end -- end -- self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_YJ_TABLE_LIST,playerID = (result.list == "" and {} or result.list)}) self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_JZ_YJ_TABLE_LIST, result = result}) else self:showError(Cmd.PHP_CLUB_JZ_GET_ZHANDUI_JZ_TABLE_LIST,response) end end) end --禁止同队,设置禁止/全部禁止 function ClubProtocolPhp:requestSetNotDeskmateteam(clubId,uid,type,uids) local param = { gid = clubId, uid = uid or 0, app = getAppId(), type = type or 0, uids = uids or 0, } app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_JZ_SET_NOT_DESK_MATE_TEAM,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if isWin32Platform() then logD("ClubProtocolPhp:requestSetNotDeskmateteam",table.tostring(response)) end if response.code == 200 then self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_BAN_ALL_BAN, Ban = 1}) else self:showError(Cmd.PHP_CLUB_JZ_SET_NOT_DESK_MATE_TEAM,response) end end) end --禁止同队,设置取消/全部取消 function ClubProtocolPhp:requestCancelNotDeskteam(clubId,uid,type,uids) local param = { gid = clubId, uid = uid or 0, app = getAppId(), type = type or 0, uids = uids or 0, } app.waitDialogManager:showWaitNetworkDialog("连接中...") self:post(Cmd.PHP_CLUB_JZ_CANCEL_NOT_DESK_MATE_TEAM,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if isWin32Platform() then logD("ClubProtocolPhp:requestCancelNotDeskteam",table.tostring(response)) end if response.code == 200 then self:dispatchEvent({name = GAME_EVENT.CLUB_PLAYER_CANCEL_ALL_CANCEL, Cancel = 1}) else self:showError(Cmd.PHP_CLUB_JZ_CANCEL_NOT_DESK_MATE_TEAM,response) end end) end --请求茶馆转让接口 function ClubProtocolPhp:requestTransfer(clubId,newOwnerId,viewType) local param = { gid = clubId, newOwner = newOwnerId, viewType = viewType or 0 } self:post(Cmd.PHP_CLUB_TRANSFER,param,function(response) logD("ClubProtocolPhp:requestTransfer",table.tostring(response)) if response.code==200 then showTooltip(app.club_php:getCestIsOpen(clubId) and PLN.CLUB_CEST_TRANSFER_SUCCESS or PLN.CLUB_TRANSFER_SUCCESS) self:dispatchEvent({name = GAME_EVENT.CLUB_SET}) else self:showError(Cmd.PHP_CLUB_TRANSFER,response) end end) end --请求设置茶馆红点 function ClubProtocolPhp:requestSetHints(clubId,hints) local param = { gid = clubId, type = hints, --"type": loghints,// loghints:茶馆消息, awardhints:奖励消息, applyhints:申请消息 value = 0,--// 0:隐藏, 1:展示 } self:post(Cmd.PHP_CLUB_SET_HINTS,param,function(response) logD("ClubProtocolPhp:requestSetHints",table.tostring(response)) if response.code==200 then local result = response.result self:updateClubHints(clubId,result) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE}) else self:showError(Cmd.PHP_CLUB_SET_HINTS,response) end end) end --请求领取奖励 function ClubProtocolPhp:requestReward(clubId, awardId, awardSN) local param = { gid = clubId, awardid = awardId, awardsn = awardSN, } self:post(Cmd.PHP_CLUB_GET_REWARD,param,function(response) logD("ClubProtocolPhp:requestReward",table.tostring(response)) if response.code==200 then local result = response.result if self.clubList[clubId].awardMessages and self.clubList[clubId].awardMessages[awardId] then self.clubList[clubId].awardMessages[awardId].status = 1 local isAwardHints = false for k,v in pairs(self.clubList[clubId].awardMessages) do if v.status==0 then isAwardHints = true end end if not isAwardHints then self:requestSetHints(clubId,"awardhints") end self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = 2}) --奖励消息tag为2 end self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_REAWRD , type = tonumber(result.atype), num = tonumber(result.prize) }) else self:showError(Cmd.PHP_CLUB_GET_REWARD,response) end end) end --茶馆主动发送广播 function ClubProtocolPhp:requestBroadcast(clubId, invitedUid, tp, content) local param = { gid = clubId, invitedUids = invitedUid, --多个用,隔开 type = tp, content = content, } self:post(Cmd.PHP_CLUB_SEND_BROADCAST,param,function(response) logD("ClubProtocolPhp:requestBroadcast",table.tostring(response)) if response.code==200 then local result = response.result showTooltip("邀请成功") app.waitDialogManager:closeAllNetWait() elseif response.code == 1070 then --玩家已屏蔽邀请,不做处理 showTooltip("邀请成功") app.waitDialogManager:closeAllNetWait() else self:showError(Cmd.PHP_CLUB_SEND_BROADCAST,response) end end) end --用户个性化设置 function ClubProtocolPhp:requestMemberSet(clubId, setType, setValues) local param = { gid = clubId, type = setType, value = setValues, } app.waitDialogManager:showWaitNetworkDialog() self:post(Cmd.PHP_CLUB_MEMBER_SET,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestMemberSet",table.tostring(response)) if response.code==200 then local contentStr = ""; if setType == 1 then contentStr = "屏蔽玩家邀请"; elseif setType == 2 and setValues == 1 then contentStr = "屏蔽开局用户"; elseif setType == 2 and setValues == 0 then contentStr = "取消屏蔽开局用户"; elseif setType == 3 and setValues == 1 then contentStr = "置顶"; elseif setType == 3 and setValues == 0 then contentStr = "取消置顶"; end local result = response.result showTooltip(contentStr.."成功") if self.clubList[clubId] then self.clubList[clubId].isHidePlay = setValues==1 end self:dispatchEvent({name = GAME_EVENT.CLUB_MEMBER_SET_SUCCESS, setType = setType, setValues = setValues, gID = gID}) else self:showError(Cmd.PHP_CLUB_MEMBER_SET,response) end end) end function ClubProtocolPhp:requestCopartnerSetup(gid, muid, uids) local param = { gid = gid, muid = muid, uids = uids, } log("ProtocolClubPhp:requestCopartnerSetup", table.tostring(param)) app.waitDialogManager:showWaitNetworkDialog() self:post(Cmd.PHP_CLUB_COPARTNER_SET_UP, param, function(response) app.waitDialogManager:closeWaitNetworkDialog() log("ProtocolClubPhp:requestCopartnerSetup", table.tostring(response)) if response.code == 200 then showTooltip("设置成功!") self:dispatchEvent({name = GAME_EVENT.CopartnerSetup, result = response.result}) else showTooltip(response.error) end end) end function ClubProtocolPhp:requestGetCopartnerSub(gid, muid) local param = { gid = gid, muid = muid, } log("ProtocolClubPhp:requestGetCopartnerSub", table.tostring(param)) app.waitDialogManager:showWaitNetworkDialog() self:post(Cmd.PHP_CLUB_GET_COPARTNER_SUB, param, function(response) app.waitDialogManager:closeWaitNetworkDialog() log("ProtocolClubPhp:requestGetCopartnerSub", table.tostring(response)) if response.code == 200 then self:dispatchEvent({name = GAME_EVENT.GetCopartnerSub, result = response.result}) else showTooltip(response.error) end end) end function ClubProtocolPhp:requestGetCopartnerStat(gid, score) local param = { gid = gid, score = score, } logD("ProtocolClubPhp:requestGetCopartnerStat tt", table.tostring(tt)) app.waitDialogManager:showWaitNetworkDialog() self:post(Cmd.PHP_CLUB_GET_COPARTNER_STAT, param, function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ProtocolClubPhp:requestGetCopartnerStat", table.tostring(response)) if response.code == 200 then self:dispatchEvent({name = GAME_EVENT.GetCopartnerStat, result = response.result}) else showTooltip(response.error) end end) end function ClubProtocolPhp:requestGetCopartnerDetail(gid, muid, score) local param = { gid = gid, muid = muid, score = score, } log("ProtocolClubPhp:requestGetCopartnerDetail", table.tostring(param)) app.waitDialogManager:showWaitNetworkDialog() self:post(Cmd.PHP_CLUB_GET_COPARTNER_DETAIL, param, function(response) app.waitDialogManager:closeWaitNetworkDialog() log("ProtocolClubPhp:requestGetCopartnerDetail", table.tostring(response)) if response.code == 200 then self:dispatchEvent({name = GAME_EVENT.GetCopartnerDetail, result = response.result}) else showTooltip(response.error) end end) end function ClubProtocolPhp:requestGetCopartnerUnionDetail(gid, muid, score,sgid) local param = { gid = gid, muid = muid, score = score, sgid = sgid, } log("ProtocolClubPhp:requestGetCopartnerUnionDetail", table.tostring(param)) app.waitDialogManager:showWaitNetworkDialog() self:post(Cmd.PHP_CLUB_UNION_DETAIL, param, function(response) app.waitDialogManager:closeWaitNetworkDialog() log("ProtocolClubPhp:requestGetCopartnerUnionDetail", table.tostring(response)) if response.code == 200 then self:dispatchEvent({name = GAME_EVENT.GetCopartnerDetail, result = response.result}) else showTooltip(response.error) end end) end function ClubProtocolPhp:requestSetRedFlower(clubId,uid,memberuid,value,callback,viewType) local param = { gid = clubId, uid = uid, --操作ID muid = memberuid, --被操作ID,"," split arena_score = value, viewType = viewType, } logD("ClubProtocolPhp:requestSetRedFlower",table.tostring(param)) self:post(Cmd.PHP_CLUB_SET_RED_FLOWER,param,function(response) logD("ClubProtocolPhp:requestSetRedFlower response",table.tostring(response)) if response.code==200 then --TODO 暂时通过推送数据修改本地数据 if callback then callback() end else self:showError(Cmd.PHP_CLUB_SET_RED_FLOWER,response) end end) end function ClubProtocolPhp:requestRedFlowerRecord(clubId,uid,memberuid,mapType,lastday,page) local param = { gid = clubId, uid = uid, --操作ID muid = memberuid, --被操作ID,"," split mapType = mapType or 0, -- {0:全部, 1:加减记录, 2赠送记录, 3赠送记录, 11:调整红花记录} lastday = lastday or 0, -- 0今天,1昨天,2前天 page = page, --[[limit = 10,--]] } --logD("ClubProtocolPhp:requestRedFlowerRecord",table.tostring(param)) self:post(Cmd.PHP_CLUB_RED_FLOWER_RECORD,param,function(response) logD("ClubProtocolPhp:requestRedFlowerRecord",table.tostring(response)) if response.code==200 then self:dispatchEvent({name = GAME_EVENT.CLUB_RED_FLOWER_RECORD, result = response.result,type = mapType}) else self:showError(Cmd.PHP_CLUB_RED_FLOWER_RECORD,response) end end) end function ClubProtocolPhp:requestCancelCoparner(clubId,ops) local param = { gid = clubId, ops = ops, } --logD("ClubProtocolPhp:requestCancelCoparner",table.tostring(param)) self:post(Cmd.PHP_CLUB_CANCELCOPARNER,param,function(response) logD("ClubProtocolPhp:requestCancelCoparner",table.tostring(response)) if response.code==200 then else if response.code == 1010 then self:dispatchEvent({name = GAME_EVENT.CLUB_CANCEL_COPARTNER_TIP}) else self:showError(Cmd.PHP_CLUB_CANCELCOPARNER,response) end end local clubInfo = self.clubList[clubId] if clubInfo then clubInfo.cancelCopartner = {} end self:dispatchEvent({name = GAME_EVENT.CLUB_CANCEL_COPARTNER, result = response.result}) end) end --请求调整合伙人成员 function ClubProtocolPhp:requestAdjustCopartnerMember(clubId,muid,uids,lastViewType,callBack,curType) local param = { gid = clubId, muid = muid, uids = uids, viewType = lastViewType, type = curType, } app.waitDialogManager:showWaitNetworkDialog("正在调配...") self:post(Cmd.PHP_CLUB_ARENACOPARTNERSETUP,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestAdjustCopartnerMember Response",table.tostring(response)) if response.code == 200 then if callBack then callBack() end self:showError(Cmd.PHP_CLUB_ARENACOPARTNERSETUP,response) else self:showError(Cmd.PHP_CLUB_ARENACOPARTNERSETUP,response) end end) end --获取单个成员信息 function ClubProtocolPhp:requestSinglePlayer(clubId,muid,viewType) local param = { gid = clubId, muid = muid, viewType = viewType, } logD("ClubProtocolPhp:requestSinglePlayer",table.tostring(param)) app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_MEMBER_INFO,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestSinglePlayer Response",table.tostring(response)) if response.code == 200 then self:updateClubPlayer(clubId,response.result,true,viewType) self:updateClubPlayer(clubId,response.result.extInfo,true,viewType) if viewType == ClubDefine.PlayListType.MATCH_MEMBER or viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER then self:dispatchEvent({name = GAME_EVENT.UPDATE_COPARTNER_RATDIO}) elseif viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_TEAM_LEVEL then self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_TEAM_LEVEL}) end else self:showError(Cmd.PHP_CLUB_MEMBER_INFO,response,response) end end) end --获取单个成员信息(合盟) function ClubProtocolPhp:requestUnionSinglePlayer(clubId,muid,viewType,sgid) local param = { gid = sgid, muid = muid, viewType = viewType, } logD("ClubProtocolPhp:requestUnionSinglePlayer",table.tostring(param)) app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_MEMBER_INFO,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestUnionSinglePlayer Response",table.tostring(response)) if response.code == 200 then response.result.sgid = sgid response.result.extInfo.sgid = sgid self:updateClubUnionClubId(clubId,response.result,false,viewType) self:updateClubUnionClubId(clubId,response.result.extInfo,false,viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_SLAVE_UPDATE_LEVEL}) self:dispatchEvent({name = GAME_EVENT.UPDATE_COPARTNER_RATDIO}) else self:showError(Cmd.PHP_CLUB_MEMBER_INFO,response,response) end end) end --获取桌子界面信息 --[[ scrollState: 0 不滑动;1:向顶,2:向底 ]] function ClubProtocolPhp:requestClubHome(clubId,gameId,ruleId,scrollState) local param = { gid = clubId, gameid = gameId, ruleid = ruleId, ver = "1.0.0", hallver = loadVersion(), } logD("ClubProtocolPhp:requestClubHome",table.tostring(param)) self:post(Cmd.PHP_CLUB_MAIN_VIEW,param,function(response) logD("ClubProtocolPhp:requestClubHomeResponse",table.tostring(response)) if response.code==200 then local result = response.result self:updateClub(result) --self:updateClubRooms(tonumber(result.gid),result.roomlist) self:updateClubBaoJians(tonumber(result.gid),result.rules) self:updateClubSettings(tonumber(result.gid),result.settings) self:dispatchEvent({name = GAME_EVENT.CLUB_TABLE, clubId = clubId,scrollState = scrollState or 1}) elseif response.code==1011 then app.waitDialogManager:showWaitNetworkDialog("连接中...") self:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM}) local function callb() app.waitDialogManager:closeWaitNetworkDialog() end self:requestClubList(callb) end end) end --- -- 游戏中杀进程重连,此时不会经过亲友圈,拿不到亲友圈配置 -- 先拉取一次配置 -- @param clubId -- @return -- function ClubProtocolPhp:requestClubHomeInGame(clubId, callback) local param = { gid = clubId, gameid = gameId, ruleid = ruleId, ver = "1.0.0", hallver = loadVersion(), } logD("ClubProtocolPhp:requestClubHome",table.tostring(param)) self:post(Cmd.PHP_CLUB_MAIN_VIEW,param,function(response) logD("ClubProtocolPhp:requestClubHomeResponse",table.tostring(response)) if response.code==200 then local result = response.result self:updateClub(result) self:updateClubBaoJians(tonumber(result.gid),result.rules) self:updateClubSettings(tonumber(result.gid),result.settings) callback(result) end end) end --激活游戏 function ClubProtocolPhp:requestActiveGame(clubId,gameId) local param = { gid = clubId, gameid = gameId, } logD("ClubProtocolPhp:requestActiveGame",table.tostring(param)) self:post(Cmd.PHP_CLUB_ACTIVE_GAME,param,function(response) logD("ClubProtocolPhp:requestActiveGameResponse",table.tostring(response)) if response.code==200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_ACTIVE_GAME, clubId = clubId}) else self:showError(Cmd.PHP_CLUB_ACTIVE_GAME,response) end end) end --激活游戏玩法 function ClubProtocolPhp:requestActiveRule(clubId,status,ruleId) local param = { gid = clubId, status = status, ruleid = ruleId, } logD("ClubProtocolPhp:requestActiveRule",table.tostring(param)) app.waitDialogManager:showWaitNetworkDialog("请稍等...") self:post(Cmd.PHP_CLUB_ACTIVE_GAME_RULE,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestActiveRuleResponse",table.tostring(response)) if response.code==200 then local result = response.result self:showError(Cmd.PHP_CLUB_ACTIVE_GAME_RULE,response,true) self:dispatchEvent({name = GAME_EVENT.CLUB_ACTIVE_RULE, clubId = clubId,status = status}) else self:showError(Cmd.PHP_CLUB_ACTIVE_GAME_RULE,response) end end) end --房间列表 function ClubProtocolPhp:requestRoomList(clubId,gameId,ruleId,page,bWait) local param = { gid = clubId, gameid = gameId, ruleid = ruleId, page = page or 1, hallver = loadVersion() } logD("ClubProtocolPhp:requestRoomList",table.tostring(param)) if bWait then app.waitDialogManager:showWaitNetworkDialog("请求房间数据...") end self:post(Cmd.PHP_CLUB_ROOMLIST,param,function(response) if bWait then app.waitDialogManager:closeWaitNetworkDialog() end logD("ClubProtocolPhp:requestRoomListResponse",table.tostring(response)) if response.code == 200 then local result = response.result if not self.clubList[tonumber(clubId)] then self.clubList[tonumber(clubId)] = {} end local club = self.clubList[tonumber(clubId)] club.isplaying = result.isplaying club.pageNum = result.pageNum or 16 --修复异常退出房间 --[[local currentView = app:getCurrentView(); if club.isplaying == 0 and currentView.__cname ~= "MainView" then app.club_php.clubID = tonumber(clubId) gotoMainView() end--]] self:updateClubRooms(tonumber(clubId),result.roomlist or {},result.posnumber) self:dispatchEvent({name = GAME_EVENT.CLUB_ROOM_LIST_UPDATE, clubId = clubId,gameId = gameId,tpage = result.tpage}) else self:showError(Cmd.PHP_CLUB_ROOMLIST,response) end end) end function ClubProtocolPhp:requestAllRankList(localData,callback) local param = { gid = localData.clubId, lastday = localData.day or 0, --0今天,1昨日, 依次类推; 默认请求0=>今日 viewType = localData.viewType, version = "20191213", } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_ALL_RANK_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestAllRankList",table.tostring(response)) end if response.code==200 then local result = response.result self:updateAllPeopleMatchData(param.gid,result,param.viewType) if callback then callback(result.list,result.memberInfo,param.viewType) end else self:showError(Cmd.PHP_CLUB_ALL_RANK_LIST,response) end end) end --战队/小队排名 function ClubProtocolPhp:requestTeamRankList(localData) local param = { gid = localData.clubId, viewType = localData.viewType, muid = localData.muid, lastmonth = localData.lastmonth, version = "20191213", } self:post(Cmd.PHP_CLUB_TEAM_RANK_LIST,param,function(response) logD("ClubProtocolPhp:requestTeamRankList",table.tostring(response)) if response.code==200 then local result = response.result self:updateClubPlayers(param.gid,result.list,param.viewType) self:updateAllPeopleMatchData(param.gid,result,param.viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid}) else self:showError(Cmd.PHP_CLUB_TEAM_RANK_LIST,response) end end) end --排名赛管理 function ClubProtocolPhp:requestMatchManage(localData) local param = { gid = localData.clubId, viewType = localData.viewType, type = localData.type, --1.排名赛管理,2下级管理,3调配成员 muid = localData.muid, isMyMem = localData.isMyMem, --1仅查看下级成员, 2查看所有 orderby = localData.orderby, --row字段都可以排序, 比如,uid, role, logion_time sort = localData.sort, --升降序 lastday = localData.lastday, --0今日,1昨日, 2前日依次类推 page = localData.page or 1, --是全部不分页,不传是0,1是第一页。 isPage = 1, suid = localData.suid } logD("============start===============",localData.viewType) app.waitDialogManager:showWaitNetworkDialog("请稍等...") app.waitDialogManager:showWaitNetworkDialog("拉取数据中...") self:post(Cmd.PHP_CLUB_WAR_MEMBER,param,function(response) if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestMatchManage",table.tostring(response)) end app.waitDialogManager:closeWaitNetworkDialog() if response.code == 200 then local result = response.result logD("============end===============",localData.viewType) if param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER then self.clubList[param.gid].playersLevelOne = {} elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER then self.clubList[param.gid].playersLevelTwo = {} elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then self.clubList[param.gid].playersLevelThree = {} end local pagePlayerList = self:updateClubPlayers(param.gid,result.list,param.viewType) self:updateAllPeopleMatchData(param.gid,result,param.viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid,result = result,pageList = pagePlayerList}) else self:showError(Cmd.PHP_CLUB_WAR_MEMBER,response) end end) end --请求战队等级提升 function ClubProtocolPhp:requestLevelUpgrade(localData,callBack) local param = { gid = localData.clubId, muid = localData.muid, viewType = localData.viewType, sgid = localData.sgid, } self:post(Cmd.PHP_CLUB_LEVEL_UPGRADE,param,function(response) logD("ClubProtocolPhp:requestLevelUpgrade",table.tostring(response)) if response.code==200 then if callBack then callBack() end showTooltip("提升成功!") local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_LEVEL_UPGRADE,response = result}) else self:showError(Cmd.PHP_CLUB_LEVEL_UPGRADE,response,true) end end) end --裁判请求--排名赛异常补偿/异常处罚(可批量) function ClubProtocolPhp:requestJudgeApply(localData) local param = { gid = localData.clubId, muid = localData.muid, -- 所有成员 value = localData.value, --大于0为补偿, 小于0为处罚 viewType = localData.viewType, type = localData.type, sgid = localData.sgid, } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_WAR_NUM_APPLY,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestJudgeApply",table.tostring(response)) if response.code==200 then local result = response.result if localData.sgid and localData.sgid > 0 then local groups = result.groups if groups then for k,v in pairs(groups) do self:updateClubUnionClubId(localData.clubId,v,true,localData.viewType) end end self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST,type = localData.viewType}) else local members = result.members for k,v in pairs(members) do self:updateClubPlayer(localData.clubId,v,true,localData.viewType) end self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = localData.viewType}) end self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_JUDGE}) self:showError(Cmd.PHP_CLUB_WAR_NUM_APPLY,response,true) else self:showError(Cmd.PHP_CLUB_WAR_NUM_APPLY,response) end end) end --排名赛:指派出赛/上报排名 function ClubProtocolPhp:requestSetMatchWarNum(localData,callBack) local param = { gid = localData.clubId, muid = localData.muid, -- 所有成员 viewType = localData.viewType, type = localData.type, warnum = localData.warnum, --小于0为上报排名; 大于0为指派出赛 sgid = localData.sgid, } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_SETMWARNUM,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestSetMatchWarNum",table.tostring(response)) if response.code == 200 then local result = response.result if localData.sgid and localData.sgid > 0 then local groups = result.groups if groups then for k,v in pairs(groups) do self:updateClubUnionClubId(localData.clubId,v,true,localData.viewType) end end self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST,type = localData.viewType}) else local members = result.members for k,v in pairs(members) do self:updateClubPlayer(localData.clubId,v,true,localData.viewType) end self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = localData.viewType}) end if callBack then callBack() end self:showError(Cmd.PHP_CLUB_SETMWARNUM,response,true) else self:showError(Cmd.PHP_CLUB_SETMWARNUM,response) end end) end --记录(上报记录/贡献记录/比赛记录) function ClubProtocolPhp:requestMatchLog(localData,callBack) local param = { gid = localData.clubId, muid = localData.muid, -- 所有成员 viewType = localData.viewType, mapType = localData.mapType, --0所有类型记录,32上报记录,35贡献记录 sgid = localData.sgid, -- 分页处理比赛记录问题 page = localData.page or 1, --是全部不分页,不传是0,1是第一页。 isPage = 1; } self:post(Cmd.PHP_CLUB_CONTENT_LOG,param,function(response) if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestMatchLog",table.tostring(response)) end if response.code==200 then local result = response.result.list -- 比赛记录 begin local allpage = 1; if localData.viewType == 3 then allpage = response.result.allpage end -- 比赛记录 end self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_LEVEL_LOG,response = result,viewType = param.viewType, allpage = allpage}) else self:showError(Cmd.PHP_CLUB_CONTENT_LOG,response) end end) end --记录(等级提升) function ClubProtocolPhp:requestMatchLevelUpgradeLog(localData) local param = { gid = localData.clubId, muid = localData.muid, viewType = localData.viewType, } self:post(Cmd.PHP_CLUB_WAR_RANKING_LIST,param,function(response) if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestMatchLevelUpgradeLog",table.tostring(response)) end if response.code==200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_MATCH_LEVEL_LOG,response = result,viewType = param.viewType}) else self:showError(Cmd.PHP_CLUB_WAR_RANKING_LIST,response) end end) end --排名分申请 function ClubProtocolPhp:requestMatchChongBangFen(localData,callback) local param = { gid = localData.clubId, warnum = localData.warnum, } self:post(Cmd.PHP_CLUB_WARNUM_APPLY,param,function(response) logD("ClubProtocolPhp:requestMatchChongBangFen",table.tostring(response)) if response.code == 200 then local result = response.result if callback then callback(result.content) end else self:showError(Cmd.PHP_CLUB_WARNUM_APPLY,response) end end) end function ClubProtocolPhp:requestMatchBaoJianTongJi(localData,callback) local param = { gid = localData.clubId, lastday = localData.lastday, --0今天1昨天..7 } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_BAOJIAN_TONGJI,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestMatchBaoJianTongJi",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result) end else self:showError(Cmd.PHP_CLUB_BAOJIAN_TONGJI,response) end end) end function ClubProtocolPhp:requestMatchTongJi(localData,callback) local param = { gid = localData.clubId, lastday = localData.lastday, --0今天1昨天..7 } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_MATCH_TONGJI,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestMatchTongJi",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result.list) end else self:showError(Cmd.PHP_CLUB_MATCH_TONGJI,response) end end) end function ClubProtocolPhp:requestClubUnionRecord(localData,callback) local tt = { gid = localData.clubId, lastday = localData.lastday, --0今天1昨天..7 } self:post(Cmd.PHP_CLUB_UNION_RECORD,tt,function(response) logD("ClubProtocolPhp:requestClubUnionRecord",table.tostring(response)) if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestClubUnionRecord",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result.list) end else self:showError(Cmd.PHP_CLUB_UNION_RECORD,response) end end) end function ClubProtocolPhp:requestMatchChouJiang(localData) local param = { gid = localData.clubId, reward_token = localData.reward_token, --服务器提供的奖励序号 idx = localData.idx, --服务器提供的领取奖励标识 } self:post(Cmd.PHP_CLUB_MATCH_CHOUJIANG,param,function(response) logD("ClubProtocolPhp:requestMatchChouJiang",table.tostring(response)) if response.code == 200 then local result = response.result else self:showError(Cmd.PHP_CLUB_MATCH_CHOUJIANG,response) end end) end function ClubProtocolPhp:requestGrantPower(localData,callback) local param = { gid = localData.clubId, muid = localData.muid, value = localData.value, viewType = localData.viewType } self:post(Cmd.PHP_CLUB_GRANT_SET,param,function(response) logD("ClubProtocolPhp:requestGrantPower",table.tostring(response)) if response.code == 200 then local result = response.result if callback then callback() end self:showError(Cmd.PHP_CLUB_GRANT_SET,response,true) else self:showError(Cmd.PHP_CLUB_GRANT_SET,response) end end) end function ClubProtocolPhp:requestCopyClub(localData) local param = { gid = localData.clubId, getgid = localData.getgid,--指定拉取成员的群 viewType = localData.viewType, } self:post(Cmd.PHP_CLUB_COPY_CLUB,param,function(response) logD("ClubProtocolPhp:requestMatchChouJiang",table.tostring(response)) if response.code == 200 then local result = response.result self:showError(Cmd.PHP_CLUB_COPY_CLUB,response) else self:showError(Cmd.PHP_CLUB_COPY_CLUB,response) end end) end function ClubProtocolPhp:getShowRooms(clubId, gameId) clubId = clubId or self.clubID gameId = gameId or self:getSelectGameId() local clubInfo = self:getClubInfo(clubId) if not clubInfo then logD("clubInfo is not exist") return end local maxPlayingRoomCount = gameId == 0 and (clubInfo.config.allPlayerPri or 10) or (clubInfo.config.playerPri or 8) local playingRoomCount = 0 local rooms = {} local hideRooms = {} local tt = self:getSortClubRooms(clubId) for i = 1, #tt do local room = tt[i] if clubInfo.groupext.is_playerpri == 0 then table.insert(rooms, room) else if room.status == 2 then -- 已开局的,限制桌数显示 if playingRoomCount < maxPlayingRoomCount then table.insert(rooms, room) playingRoomCount = playingRoomCount + 1 else table.insert(hideRooms, room) end else table.insert(rooms, room) end end end return rooms, hideRooms; end --params{master_union:{1关闭2开启}; slave_union:{1关闭2开启} } function ClubProtocolPhp:requestUnionSwitch(clubId,localData) local tt = { gid = clubId, params = json.encode(localData), } self:post(Cmd.PHP_CLUB_UNION_SWITCH,tt,function(response) logD("ClubProtocolPhp:requestMatchChouJiang",table.tostring(response)) if response.code == 200 then local result = response.result if localData.master_union == 2 then response.code = response.code + 1 self:showError(Cmd.PHP_CLUB_UNION_SWITCH ,response,true) elseif localData.slave_union == 2 then response.code = response.code + 2 self:showError(Cmd.PHP_CLUB_UNION_SWITCH,response,true) else self:showError(Cmd.PHP_CLUB_UNION_SWITCH,response,true) end local clubInfo = self.clubList[tonumber(clubId)] if clubInfo then local groupext = clubInfo.groupext groupext.master_union = localData.master_union groupext.slave_union = localData.slave_union groupext.union_agree = localData.union_agree end self:dispatchEvent({name = GAME_EVENT.CLUB_SET, clubId = clubId}) else self:showError(Cmd.PHP_CLUB_UNION_SWITCH,response) end end) end --搜索主盟 function ClubProtocolPhp:requestSearchMasterUnion(localData,callback) local tt = { gid = localData.clubId, mastergid = localData.mastergid, } self:post(Cmd.PHP_CLUB_SEARCH_MATER_UNION,tt,function(response) logD("ClubProtocolPhp:requestSearchMasterUnion",table.tostring(response)) if response.code == 200 then else local code = response.code local cmd = Cmd.PHP_CLUB_SEARCH_MATER_UNION if code then if ClubDefine.Error[cmd] and ClubDefine.Error[cmd][code] then response.error = ClubDefine.Error[cmd][code] else response.error = "错误码:"..code end else response.error = "未知错误!" end end if callback then callback(response) end end) end --查询主盟 function ClubProtocolPhp:requestCheckMasterUnion(clubId) local tt = { gid = clubId, } app.waitDialogManager:showWaitNetworkDialog("查询主盟...") self:post(Cmd.PHP_CLUB_GET_UNION_MASTER_INFO,tt,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestCheckMasterUnion",table.tostring(response)) if response.code == 200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_CHECK_MASTER, clubId = clubId,result = result}) else self:showError(Cmd.PHP_CLUB_GET_UNION_MASTER_INFO,response) end end) end --加入主盟 function ClubProtocolPhp:requestJoinMasterUnion(localData,callBack) local tt = { gid = localData.clubId, mastergid = localData.mastergid, } app.waitDialogManager:showWaitNetworkDialog("正在申请...") self:post(Cmd.PHP_CLUB_APPLY_MATER_UNION,tt,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestJoinMasterUnion",table.tostring(response)) if response.code == 200 then local result = response.result response.okCallBack = callBack end self:showError(Cmd.PHP_CLUB_APPLY_MATER_UNION,response) end) end --主盟请求加入的副盟列表 function ClubProtocolPhp:requestJoinMasterUnionList(localData) local param = { gid = localData.clubId, type = localData.type, lastday = localData.lastday or 0, viewType = localData.viewType, score = localData.score or 0, } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_MATER_UNION_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestJoinMasterUnionList",table.tostring(response)) if response.code == 200 then local result = response.result if result and table.nums(result.list) == 0 then self.clubList[tonumber(localData.clubId)].unionPlayerList = {} end self:updateClubUnionClub(param.gid,result.list,param.viewType) self:updateAllPeopleMatchData(param.gid,result,param.viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_JOIN_MASTER_LIST, type = param.viewType,clubId = localData.clubId,result = result}) else self:showError(Cmd.PHP_CLUB_MATER_UNION_LIST,response) end end) end --主盟msg function ClubProtocolPhp:requestMasterUnionMessage(clubId) local tt = { gid = clubId, } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_MATER_UNION_MESSAGE,tt,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestMasterUnionMessage",table.tostring(response)) if response.code == 200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_MESSAGE, clubId = clubId,result = result}) else self:showError(Cmd.PHP_CLUB_MATER_UNION_MESSAGE,response) end end) end --合盟信息审批 function ClubProtocolPhp:requestMasterUnionMessageJudge(localData) local tt = { gid = localData.clubId, ops = localData.ops, value = localData.value, id = localData.id, viewType = localData.viewType, } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_MATER_UNION_MESSAGE_JUDGE,tt,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestMasterUnionMessageJudge",table.tostring(response)) if response.code == 200 then local result = response.result --更新列表 self:requestMasterUnionMessage(localData.clubId) else self:showError(Cmd.PHP_CLUB_MATER_UNION_MESSAGE_JUDGE,response) end end) end --合盟解散主盟 function ClubProtocolPhp:requestMasterUnionDissmiss(localData,callback) local tt = { gid = localData.clubId, viewType = localData.viewType } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_SLAVE_UNION_DISSMISS,tt,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestMasterUnionDissmiss",table.tostring(response)) if response.code == 200 then local result = response.result self:showError(Cmd.PHP_CLUB_SLAVE_UNION_DISSMISS,response,true) if callback then callback() end else self:showError(Cmd.PHP_CLUB_SLAVE_UNION_DISSMISS,response) end end) end --盟主发起冻结,取消冻结,解散关系,比例调配等操作 --[[ $type : { 1状态操作 $value 1正常2冻结0解散 2贡献分配 $value 0~100 } ]] function ClubProtocolPhp:requestMasterUnionOps(localData,callback) local tt = { gid = localData.clubId, type = localData.type, value = localData.value, sgid = localData.sgid, viewType = localData.viewType, } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_MASTER_UNION_SETUP,tt,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestMasterUnionOps",table.tostring(response)) if response.code == 200 then local result = response.result self:showError(Cmd.PHP_CLUB_MASTER_UNION_SETUP,response,true) if localData.type == 1 then app.club_php:requestJoinMasterUnionList(localData) end else self:showError(Cmd.PHP_CLUB_MASTER_UNION_SETUP,response) end end) end function ClubProtocolPhp:updateClubUnionClub(clubId,slaveUnionClubIdList,mType,dateType) if not slaveUnionClubIdList then return end if not self.clubList[clubId] then return end local club = self.clubList[clubId] --[[if club.playersMatch then for k,v in pairs(club.playersMatch) do v.viewType = nil end end--]] for k,v in pairs(slaveUnionClubIdList) do self:updateClubUnionClubId(clubId,v,nil,mType,dateType) end end function ClubProtocolPhp:updateClubUnionClubId(clubId,v,isModified,mType,dateType) if not self.clubList[clubId] or not v then return end mType = mType or ClubDefine.PlayListType.UNION_CLUB_LIST local club = self.clubList[clubId] if not club.unionPlayerList then club.unionPlayerList={} end if not club.mySelfData then club.mySelfData = {} end local curUnionClubData = nil if mType == ClubDefine.PlayListType.UNION_CLUB_LIST then curUnionClubData = club.unionPlayerList if tonumber(v.sgid) == self.clubID then curUnionClubData = club.mySelfData end end if not curUnionClubData[tonumber(v.sgid)] then if isModified then --如果是修改没有数据直接return return end curUnionClubData[tonumber(v.sgid)] = {} end local slaveUnion = curUnionClubData[tonumber(v.sgid)] slaveUnion.viewType = mType slaveUnion.uid = v.uid and tonumber(v.uid) or slaveUnion.uid slaveUnion.name = v.nick or slaveUnion.name slaveUnion.sex = tonumber(v.sex) or slaveUnion.sex --玩家性别:0未知1男2女 slaveUnion.strHeadUrl = v.icon or slaveUnion.strHeadUrl --玩家头像地址 slaveUnion.desc = v.desc or slaveUnion.desc --备注 slaveUnion.lastPlayNum = v.last_play_number or slaveUnion.lastPlayNum --昨日局数 slaveUnion.lastPlayWinNum = v.last_play_win_number or slaveUnion.lastPlayWinNum --昨日大赢家次数 slaveUnion.online = tonumber(v.online) or slaveUnion.online --1在线0离线 slaveUnion.loginTime = tonumber(v.login_time) or slaveUnion.loginTime --最近登录的时间戳, 如果数值为0, 直接为离线 slaveUnion.role = tonumber(v.role) or slaveUnion.role or 0 --1成员2管理员3创建人 slaveUnion.status = tonumber(v.status) or slaveUnion.status or 0 --1正常0黑名单成员-1退出群 slaveUnion.lastTotalScore = v.last_total_score or slaveUnion.lastTotalScore --昨日输赢积分 slaveUnion.copartner = tonumber(v.copartner) or slaveUnion.copartner --所属普通合伙人/二级合伙人/直属上级UID slaveUnion.copartner_role = v.copartner_role or slaveUnion.copartner_role --所属普通合伙人/二级合伙人 slaveUnion.copartner_nick = v.copartner_nick or slaveUnion.copartner_nick --所属普通合伙人/二级合伙人/战队名 slaveUnion.copartner5 = tonumber(v.copartner5) or slaveUnion.copartner5 --所属一级合伙人ID slaveUnion.copartner5_nick = v.copartner5_nick or slaveUnion.copartner5_nick --所属一级合伙人NICK --数据分类处理,防止数据重复覆盖 if mType == ClubDefine.PlayListType.UNION_CLUB_LIST then --玩家数据 slaveUnion.id = tonumber(v.id) or slaveUnion.id --id排序 slaveUnion.sgid = tonumber(v.sgid) or slaveUnion.sgid --合盟申请的亲友圈id slaveUnion.sgname = v.sgname or slaveUnion.sgname --合盟群昵称 slaveUnion.nick = v.nick or slaveUnion.nick --合盟馆主昵称 slaveUnion.arenaRatio = v.arena_ratio or slaveUnion.arenaRatio or 0 -- 贡献比例 slaveUnion.status = v.status or slaveUnion.status --1正常2冻结 slaveUnion.create_time = v.create_time or slaveUnion.create_time --加入时间 slaveUnion.warnum = tonumber(v.warnum) or slaveUnion.warnum --排名分 slaveUnion.medal = tonumber(v.medal) or slaveUnion.medal --勋章 slaveUnion.arenaSprint = tonumber(v.arena_sprint) or slaveUnion.arenaSprint --初始化分 slaveUnion.arenaReport = tonumber(v.arena_report) or slaveUnion.arenaReport --上报分 slaveUnion.playNum = tonumber(v.play_number) or slaveUnion.playNum --局数 slaveUnion.totalScore = v.total_score or slaveUnion.totalScore --输赢积分 slaveUnion.honor = tonumber(v.honor) or slaveUnion.honor --抽奖 slaveUnion.captainLevel = tonumber(v.captain_level) or slaveUnion.captainLevel --当前队长等级 slaveUnion.level = tonumber(v.user_level) or slaveUnion.level --当前队长等级 slaveUnion.haveRole5 = v.haveRole5 or slaveUnion.haveRole5 or 0 --该盟主名下含有的队长数量 slaveUnion.playWinNum = tonumber(v.play_win_number) or slaveUnion.playWinNum --大赢家次数 slaveUnion.data = v.data or slaveUnion.data --常规赛合伙人贡献点 --[[if slaveUnion.uid == app.user.loginInfo.uid and club.memberInfo then club.memberInfo.warnum = slaveUnion.warnum self:dispatchEvent({name = GAME_EVENT.CLUB_UPDATE_RED_FLOWER}) end--]] --[[ slaveUnion.level = tonumber(v.user_level) or slaveUnion.level or 1 --玩牌等级 slaveUnion.copartner6 = v.copartner6 or slaveUnion.copartner6 --所属二级合伙人ID slaveUnion.arenaRatio = v.arena_ratio or slaveUnion.arenaRatio or 0 -- 分成比例 slaveUnion.copartnerSubStatus = v.copartnerSubStatus or slaveUnion.copartnerSubStatus or 0 -- 对合伙人有效, 1表示可冻结所有下属0表示解冻,-1无权对此合伙人批量处理/或是成员 slaveUnion.grant = v.grant or slaveUnion.grant or 0 --管理员所拥有的权限(裁判,上报排名,指派出赛) --]] end end function ClubProtocolPhp:requestClubBelong() local tt = { } app.waitDialogManager:showWaitNetworkDialog("请求中...") self:post(Cmd.PHP_CLUB_UNION_BELONG,tt,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestClubBelong",table.tostring(response)) if response.code == 200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_CLUB_BELONG, result = result}) else self:showError(Cmd.PHP_CLUB_UNION_BELONG,response) end end) end function ClubProtocolPhp:requestClubBelongList() local tt = { } self:post(Cmd.PHP_CLUB_LOCAL_UNION,tt,function(response) logD("ClubProtocolPhp:requestClubBelongList",table.tostring(response)) if response.code == 200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_UNION_CLUB_BELONG_LIST, result = result}) else self:showError(Cmd.PHP_CLUB_LOCAL_UNION,response) end end) end function ClubProtocolPhp:requestClubSetBelong(clubId,callback) local tt = { gid = clubId } self:post(Cmd.PHP_CLUB_BELONG_SET,tt,function(response) logD("ClubProtocolPhp:requestClubSetBelong",table.tostring(response)) if response.code == 200 then local result = response.result if callback then callback() end self:showError(Cmd.PHP_CLUB_BELONG_SET,response,true) else self:showError(Cmd.PHP_CLUB_BELONG_SET,response) end end) end function ClubProtocolPhp:requestClubReportRank(clubId,muid,day) local tt = { gid = clubId, auid = app.user.loginInfo.uid, muid = muid, date = day, viewType = ClubDefine.PlayListType.NORMAL_MEMBER, } self:post(Cmd.PHP_CLUB_SHANG_BAO,tt,function(response) logD("ClubProtocolPhp:requestClubReportRank",table.tostring(response)) if response.code == 200 then local result = response.result self:showError(Cmd.PHP_CLUB_SHANG_BAO,response,true) else self:showError(Cmd.PHP_CLUB_SHANG_BAO,response) end end) end function ClubProtocolPhp:requestNormalRank(localData,callback) local param = { gid = localData.clubId, date = localData.lastday, --0今天1昨天..7 } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CHECK_RANK,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestNormalRankResponse",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result) end else self:showError(Cmd.PHP_CLUB_CHECK_RANK,response) end end) end --cest -- cest初始参数信息 function ClubProtocolPhp:updateCestGameset(messages) if not messages then return end local club = self.clubCestInfo club.points = {} -- 赛场设置,积分数组 club.gamenums = {} -- 赛场设置,每轮局数数组 club.applynums = {} -- 申请参赛名额数组,队长 club.applynums1 = {} -- 申请参赛名额数组,小队长 club.applynums2 = {} -- 申请参赛名额数组,小组长 local _messages = json.decode(messages) local _point = string.split(_messages.point,",") for _, v in ipairs(_point) do table.insert(club.points, v) end local _gamenum = string.split(_messages.gamenum,",") for _, v in ipairs(_gamenum) do table.insert(club.gamenums, v) end if _messages.applynum then local _applynum = string.split(_messages.applynum,",") for _, v in ipairs(_applynum) do table.insert(club.applynums, v) end end if _messages.applynum1 then local _applynum1 = string.split(_messages.applynum1,",") for _, v in ipairs(_applynum1) do table.insert(club.applynums1, v) end end if _messages.applynum2 then local _applynum2 = string.split(_messages.applynum2,",") for _, v in ipairs(_applynum2) do table.insert(club.applynums2, v) end end club.max_contribute = _messages.contribute or 30 -- 最高赛点,比赛设置里面使用 -- logD("lwq_updateCestGameset"..table.tostring(self.clubCestInfo)) end --cest --获取初始参数信息 function ClubProtocolPhp:requestCestGetGameSet(clubId) local param = { gid = clubId, uid = app.user.loginInfo.uid, app = getAppId(), } self:post(Cmd.PHP_CLUB_CEST_GET_GAMESET,param,function(response) logD("ClubProtocolPhp:requestCestGetGameSet",table.tostring(response)) if response.code==200 then local result = response.result self:updateCestGameset(result) self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GET_GAMESET}) else self:showError(Cmd.PHP_CLUB_CEST_GET_GAMESET,response) end end) end -- cest --战队/小队排名 function ClubProtocolPhp:requestCestTeamRankList(localData) local param = { gid = localData.clubId, uid = app.user.loginInfo.uid, app = getAppId(), page = localData.page, orderby = localData.orderby, sort = localData.sort, --升降序 -- lastmonth = localData.lastmonth, lastday = localData.lastmonth, viewType = localData.viewType, version = "20191213", -- suid = localData.suid, } app.waitDialogManager:showWaitNetworkDialog("请稍等...") self:post(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,param,function(response) logD("ClubProtocolPhp:requestCestTeamRankList",table.tostring(response)) app.waitDialogManager:closeWaitNetworkDialog() if response.code==200 then local result = response.result self:updateClubPlayers(param.gid,result.list,param.viewType) self:updateAllPeopleMatchData(param.gid,result,param.viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid, allpage = result.allpage}) else self:showError(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,response) end end) end -- cest --战队/小队排名,查自己的排名 function ClubProtocolPhp:requestCestTeamMyselfRank(localData, callback) local param = { gid = localData.clubId, uid = app.user.loginInfo.uid, app = getAppId(), page = localData.page, orderby = localData.orderby, sort = localData.sort, --升降序 -- lastmonth = localData.lastmonth, lastday = localData.lastmonth, viewType = localData.viewType, version = "20191213", -- suid = localData.suid, type = 2, -- 老麦说,战队排名里面传2 } self:post(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,param,function(response) if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestCestTeamMyselfRank",table.tostring(response)) end if response.code==200 then local result = response.result -- self:updateClubPlayers(param.gid,result.list,param.viewType) -- self:updateAllPeopleMatchData(param.gid,result,param.viewType) -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid, allpage = result.allpage}) if callback then callback(result.memberInfo) end else self:showError(Cmd.PHP_CLUB_CEST_TEAM_RANK_LIST,response) end end) end -- cest -- 认领比赛接口 function ClubProtocolPhp:requestCestDrawTeam(localData, callBack) local param = { gid = localData.clubId, uid = app.user.loginInfo.uid, app = getAppId(), oneNum = localData.oneNum, twoNum = localData.twoNum, threeNum = localData.threeNum, } self:post(Cmd.PHP_CLUB_CEST_DRAW_TEAM,param,function(response) logD("ClubProtocolPhp:requestCestDrawTeam",table.tostring(response)) if response.code==200 then if callBack then callBack() end showTooltip("认领比赛成功") self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_DRAW_TEAM,param = param}) else self:showError(Cmd.PHP_CLUB_CEST_DRAW_TEAM,response) end end) end -- cest -- 结束比赛接口 function ClubProtocolPhp:requestCestEndTeam(localData, callBack) local param = { gid = localData.clubId, uid = app.user.loginInfo.uid, app = getAppId(), } self:post(Cmd.PHP_CLUB_CEST_END_TEAM,param,function(response) logD("ClubProtocolPhp:requestCestEndTeam",table.tostring(response)) if response.code==200 then if callBack then callBack() end showTooltip("结束比赛成功") self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_END_TEAM,param = param}) else self:showError(Cmd.PHP_CLUB_CEST_END_TEAM,response) end end) end --cest function ClubProtocolPhp:updateCestInfo(clubId, messages) if not messages then return end -- local club = self.clubCestInfo -- club.one_gamenum = messages.one_gamenum -- club.one_point = messages.one_point -- club.two_gamenum = messages.two_gamenum -- club.two_point = messages.two_point -- club.three_gamenum = messages.three_gamenum -- club.three_point = messages.three_point local clubInfo = self:getClubInfo(clubId) if clubInfo.groupext.cestext then clubInfo.groupext.cestext.one_gamenum = messages.one_gamenum or 0 clubInfo.groupext.cestext.one_point =messages.one_point or 0 clubInfo.groupext.cestext.two_gamenum =messages.two_gamenum or 0 clubInfo.groupext.cestext.two_point =messages.two_point or 0 clubInfo.groupext.cestext.three_gamenum =messages.three_gamenum or 0 clubInfo.groupext.cestext.three_point =messages.three_point or 0 clubInfo.groupext.cestext.mid_point =messages.mid_point or 0 clubInfo.groupext.cestext.mid_gamenum =messages.mid_gamenum or 0 end end -- cest -- 报名开始接口 function ClubProtocolPhp:requestCestGameInfo(localData) local param = { gid = localData.clubId, uid = app.user.loginInfo.uid, app = getAppId(), } self:post(Cmd.PHP_CLUB_CEST_GAMEINFO,param,function(response) logD("ClubProtocolPhp:requestCestGameInfo",table.tostring(response)) if response.code==200 then -- showTooltip("报名开始") self:updateCestInfo(localData.clubId, response.result) -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GAMEINFO,param = response.result}) self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_GAMEINFO}) else self:showError(Cmd.PHP_CLUB_CEST_GAMEINFO,response) self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_NO_GAMEINFO}) end end) end -- cest -- 报名参加接口 function ClubProtocolPhp:requestCestStartApply(localData, callBack) local param = { gid = localData.clubId, uid = app.user.loginInfo.uid, app = getAppId(), type = localData.type } self:post(Cmd.PHP_CLUB_CEST_START_APPLY,param,function(response) logD("ClubProtocolPhp:requestCestStartApply",table.tostring(response)) if response.code==200 then if callBack then callBack() end showTooltip("报名参加成功") -- 成功后,修改成报名审核中 local club = self.clubCestInfo club.type = localData.type club.status = ClubDefine.SaichangStatus.Shenhe self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_START_APPLY,param = param}) else self:showError(Cmd.PHP_CLUB_CEST_START_APPLY,response) if callBack then callBack() end end end) end -- cest -- 海选赛申请列表接口 function ClubProtocolPhp:requestCestApplyList(localData, callBack) local param = { gid = localData.clubId, uid = app.user.loginInfo.uid, app = getAppId(), msgtype = localData.msgtype, isMyMem = localData.isMyMem, --1仅查看下级成员, 2查看所有 suid = localData.suid, page = localData.page, } self:post(Cmd.PHP_CLUB_CEST_APPLY_LIST,param,function(response) logD("ClubProtocolPhp:requestCestApplyList",table.tostring(response)) if response.code==200 then if callBack then callBack() end local result = response.result self:updateClubCestMessages(localData.clubId,result.lists) self:updateClubHints(localData.clubId,result) -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_LIST,tag = ClubDefine.ClubMessage.CEST_MESSAGE}) self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_BTN,msgtype = localData.msgtype, pagenum = result.pagenum}) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MESSAGE}) --茶馆消息tag为1 else if response.error == "您输入的ID有误或不在海选赛" then showTooltip("您输入的ID有误或不在海选赛") else self:showError(Cmd.PHP_CLUB_CEST_APPLY_LIST,response) end end end) end -- cest function ClubProtocolPhp:updateClubCestMessageApplyStatus(clubId,messageId,status,id,name) local club = self.clubList[clubId] if not club then return end if club.cestMessages then for i,msg in pairs(club.cestMessages) do if msg.messageId==messageId then msg.status = status end end end end -- cest -- 海选赛报名审核接口 function ClubProtocolPhp:requestCestApplyStatus(clubId, id, status) local param = { gid = clubId, uid = app.user.loginInfo.uid, app = getAppId(), id = id, ops = status, } app.waitDialogManager:showWaitNetworkDialog() self:post(Cmd.PHP_CLUB_CEST_APPLY_STATUS,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestCestApplyStatus",table.tostring(response)) if response.code==200 then --修改状态 self:updateClubCestMessageApplyStatus(clubId,id,status) --检测处理完成后设置红点不显示 local isApplyHints = false for k,v in pairs(self.clubList[clubId].cestMessages) do if v.status==0 then isApplyHints = true end end if not isApplyHints and self.clubList[clubId].role ~= ClubDefine.Job.LevelOneCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelTwoCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelThreeCopartner then -- self:requestSetHints(clubId,"warnumhints") -- 之后再找老麦处理 end -- self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.ALL_PEOPLE_MATCH_APPLY}) -- self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED}) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MESSAGE}) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED}) -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_STATUS,result = response.result}) else self:showError(Cmd.PHP_CLUB_CEST_APPLY_STATUS,response) end end) end --CEST --海选赛管理 function ClubProtocolPhp:requestCestManage(localData) local param = { gid = localData.clubId, viewType = localData.viewType, type = localData.type, --1.排名赛管理,2下级管理,3调配成员 muid = localData.muid, isMyMem = localData.isMyMem, --1仅查看下级成员, 2查看所有 orderby = localData.orderby, --row字段都可以排序, 比如,uid, role, logion_time sort = localData.sort, --升降序 lastday = localData.lastday, --0今日,1昨日, 2前日依次类推 page = localData.page or 1, --是全部不分页,不传是0,1是第一页。 isPage = 1, suid = localData.suid } logD("============startcest===============",localData.viewType) app.waitDialogManager:showWaitNetworkDialog("请稍等...") -- app.waitDialogManager:showWaitNetworkDialog("拉取数据中...") self:post(Cmd.PHP_CLUB_CEST_MEMBER,param,function(response) if cc.Application:getInstance():getTargetPlatform() == 0 then logD("接口名字", Cmd.PHP_CLUB_CEST_MEMBER) logD("ClubProtocolPhp:requestCestManage",table.tostring(response)) end app.waitDialogManager:closeWaitNetworkDialog() if response.code == 200 then local result = response.result logD("============endcest===============",localData.viewType) if param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_1_COPARTNER_MEMBER then self.clubList[param.gid].playersLevelOne = {} elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_2_COPARTNER_MEMBER then self.clubList[param.gid].playersLevelTwo = {} elseif param.viewType == ClubDefine.PlayListType.ALL_PEOPLE_MATCH_LV_3_COPARTNER_MEMBER then self.clubList[param.gid].playersLevelThree = {} end local pagePlayerList = self:updateClubPlayers(param.gid,result.list,param.viewType) self:updateAllPeopleMatchData(param.gid,result,param.viewType) self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = param.viewType,clubId = param.gid,result = result,pageList = pagePlayerList}) else self:showError(Cmd.PHP_CLUB_CEST_MEMBER,response) end end) end --CEST --海选赛排名 function ClubProtocolPhp:requestCestAllRankList(localData,callback) local param = { app = getAppId(), -- uid = app.user.loginInfo.uid, -- gid = localData.clubId, lastday = localData.day or 0, --0今天,1昨日, 依次类推; 默认请求0=>今日 viewType = localData.viewType, version = "20191213", } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_ALL_RANK_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestCestAllRankList",table.tostring(response)) end if response.code==200 then local result = response.result self:updateAllPeopleMatchData(param.gid,result,param.viewType) if callback then callback(result.list,result.memberInfo,param.viewType) end else self:showError(Cmd.PHP_CLUB_CEST_ALL_RANK_LIST,response) end end) end --CEST --海选赛申请退赛 function ClubProtocolPhp:requestCestDrawEndGame(clubId,callback) local param = { app = getAppId(), -- uid = app.user.loginInfo.uid, -- gid = clubId, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_DRAW_END_GAME,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestCestDrawEndGame",table.tostring(response)) if response.code==200 then local result = response.result -- 成功后,修改成退赛申请中 local club = self.clubCestInfo club.type = ClubDefine.Saichang.Tuisai club.status = ClubDefine.SaichangStatus.Shenhe self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_END_GAME}) else self:showError(Cmd.PHP_CLUB_CEST_DRAW_END_GAME,response) end end) end -- cest -- 获取个人信息 function ClubProtocolPhp:requestCestUserInfo(clubId) local param = { gid = clubId, uid = app.user.loginInfo.uid, app = getAppId(), } self:post(Cmd.PHP_CLUB_CEST_USER_INFO,param,function(response) logD("ClubProtocolPhp:requestCestUserInfo",table.tostring(response)) if response.code==200 then -- type 为 1,2 ,3,的时候 status 状态,0,未领取,1领取 ,2审核中 , -- type 为4 是退赛,这时status 2是退赛申请 ,type如果0也是没有申请 local club = self.clubCestInfo club.point = response.result.point or 0 club.contribute = response.result.contribute or 0 club.type = response.result.type or 0 club.status = response.result.status or 0 club.curgamenum = response.result.curgamenum or 0 -- 当前局数 club.gamenum = response.result.gamenum or 0 -- 总局数 self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_USER_INFO}) else --ljx 麦总要求这里上传日志让他看看什么情况 uploadLogs(Cmd.PHP_CLUB_CEST_USER_INFO.."Error") self:showError(Cmd.PHP_CLUB_CEST_USER_INFO,response) end end) end -- cest -- 终止比赛 function ClubProtocolPhp:requestCestEndGame(clubId, muid, viewType) local param = { app = getAppId(), gid = clubId, uid = app.user.loginInfo.uid, muid = muid, -- 所有成员 viewType = viewType, -- type = localData.type, -- sgid = localData.sgid, } app.waitDialogManager:showWaitNetworkDialog("请求中...") -- self:post(Cmd.PHP_CLUB_WAR_NUM_APPLY,param,function(response) self:post(Cmd.PHP_CLUB_CEST_END_GAME,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestCestEndGame",table.tostring(response)) if response.code==200 then showTooltip("操作成功") local result = response.result local members = result.members for k,v in pairs(members) do self:updateClubPlayer(clubId,v,true,viewType) end self:dispatchEvent({name = GAME_EVENT.CLUB_ALL_PEOPLE_MATCH,type = viewType}) self:dispatchEvent({name = GAME_EVENT.NOTICE_REQUEST_PLAYER_LIST}) else if response.error then response.error = string.gsub(response.error, "无法上报", "无法操作") end self:showError(Cmd.PHP_CLUB_CEST_END_GAME,response) end end) end -- cest -- 比赛局数统计 function ClubProtocolPhp:requestCestBaoJianTongJi(localData,callback) local param = { gid = localData.clubId, lastday = localData.lastday, --0今天1昨天..7 } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_BAOJIAN_TONGJI,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestCestBaoJianTongJi",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result) end else self:showError(Cmd.PHP_CLUB_CEST_BAOJIAN_TONGJI,response) end end) end -- cest -- 赛事纪录 function ClubProtocolPhp:requestCestTongJi(localData,callback) local param = { gid = localData.clubId, lastday = localData.lastday, --0今天1昨天..7 muid = localData.muid, --查看的玩家ID } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_TONGJI,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestCestTongJi",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result.list) end else self:showError(Cmd.PHP_CLUB_CEST_TONGJI,response) end end) end -- cest -- 申请记录 --记录 function ClubProtocolPhp:requesCestApplyRecordList(localData) local param = { gid = localData.clubId, muid = localData.muid, -- viewType = localData.viewType, app = getAppId(), uid = app.user.loginInfo.uid, } self:post(Cmd.PHP_CLUB_CEST_APPLY_RECORD_LIST,param,function(response) if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requesCestApplyRecordList",table.tostring(response)) end if response.code==200 then local result = response.result self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_APPLY_LOG,response = result,viewType = param.viewType}) else self:showError(Cmd.PHP_CLUB_CEST_APPLY_RECORD_LIST,response) end end) end -- cest -- 游戏信息 function ClubProtocolPhp:requesCestMinge(callback, clubId, applynum) local param = { app = getAppId(), uid = app.user.loginInfo.uid, gid = clubId, applynum = applynum, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_APPLY_MINGE,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requesCestMinge",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result) end self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_CANSAI_MINGE,response = result}) else self:showError(Cmd.PHP_CLUB_CEST_APPLY_MINGE,response) end end) end --海选赛申请 function ClubProtocolPhp:updateClubCestMinge(clubId,messages) if not messages then return end if not self.clubList[clubId] then self.clubList[clubId] = {} end local club = self.clubList[clubId] club.cestMinge={} for _,msg in pairs(messages) do if not club.cestMinge[tonumber(msg.id)] then club.cestMinge[tonumber(msg.id)] = {} end local messageItem = club.cestMinge[tonumber(msg.id)] messageItem.messageId = tonumber(msg.id) messageItem.clubId = tonumber(msg.gid) messageItem.uid = tonumber(msg.uid) messageItem.nick = msg.nick or "" messageItem.icon = msg.icon or "" messageItem.role = tonumber(msg.role) messageItem.applynum = tonumber(msg.applynum) messageItem.applyTime = tonumber(msg.apply_time) messageItem.endTime = tonumber(msg.end_time) messageItem.status = tonumber(msg.status) messageItem.operuid = tonumber(msg.operuid) end end -- cest -- 报名参赛申请名额列表 function ClubProtocolPhp:requesCestMingeList(clubId, callback) local param = { app = getAppId(), uid = app.user.loginInfo.uid, gid = clubId, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_APPLY_MINGE_LIST,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requesCestMingeList",table.tostring(response)) end if response.code==200 then if callBack then callBack() end local result = response.result self:updateClubCestMinge(clubId,result.lists) self:updateClubHints(clubId,result) -- self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MESSAGE}) --茶馆消息tag为1 self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MINGE}) --茶馆消息tag为1 else self:showError(Cmd.PHP_CLUB_CEST_APPLY_MINGE_LIST,response) end end) end -- cest function ClubProtocolPhp:updateClubCestMingeApplyStatus(clubId,messageId,status,id,name) local club = self.clubList[clubId] if not club then return end if club.cestMinge then for i,msg in pairs(club.cestMinge) do if msg.messageId==messageId then msg.status = status end end end end -- cest -- 海选赛申请名额审核 function ClubProtocolPhp:requestCestMingeStatus(clubId, id, status) local param = { gid = clubId, uid = app.user.loginInfo.uid, app = getAppId(), id = id, ops = status, } self:post(Cmd.PHP_CLUB_CEST_APPLY_MINGE_STATUS,param,function(response) logD("ClubProtocolPhp:requestCestMingeStatus",table.tostring(response)) if response.code==200 then --修改状态 self:updateClubCestMingeApplyStatus(clubId,id,status) --检测处理完成后设置红点不显示 local isApplyHints = false for k,v in pairs(self.clubList[clubId].cestMinge) do if v.status==0 then isApplyHints = true end end if not isApplyHints and self.clubList[clubId].role ~= ClubDefine.Job.LevelOneCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelTwoCopartner and self.clubList[clubId].role ~= ClubDefine.Job.LevelThreeCopartner then -- self:requestSetHints(clubId,"warnumhints") -- 之后再找老麦处理 end self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE , tag = ClubDefine.ClubMessage.CEST_MINGE}) self:dispatchEvent({name = GAME_EVENT.CLUB_MESSAGE_CHANGED}) else self:showError(Cmd.PHP_CLUB_CEST_APPLY_MINGE_STATUS,response) end end) end -- cest -- 参赛名额信息 function ClubProtocolPhp:requesCestMingeInfo(callback, clubId, lastday) local param = { app = getAppId(), uid = app.user.loginInfo.uid, gid = clubId, lastday = lastday, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_MINGE_INFO,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requesCestMingeInfo",table.tostring(response)) if response.code==200 then local result = response.result if callback then callback(result) end -- self:dispatchEvent({name = GAME_EVENT.CLUB_CEST_CANSAI_MINGE,response = result}) else self:showError(Cmd.PHP_CLUB_CEST_MINGE_INFO,response) end end) end -- cest -- 参赛名额信息 function ClubProtocolPhp:requesCestGameNum(callback, clubId, muid) local param = { app = getAppId(), uid = muid, gid = clubId, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_GET_GAMENUM,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requesCestGameNum",table.tostring(response)) if response.code==200 then local result = response.result if callback then callback(result) end else self:showError(Cmd.PHP_CLUB_CEST_GET_GAMENUM,response) end end) end -- tianti -- 获取sms function ClubProtocolPhp:requestTiantiSms(phone,callback) local param = { phone = phone, uid = app.user.loginInfo.uid, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_TIANTI_AUTHTOKEN,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if response.code==200 then local result = response.result if callback then -- callback(result.list) -- callback(result) end showTooltip("验证码获取成功") else self:showError(Cmd.PHP_CLUB_TIANTI_AUTHTOKEN,response) end end) end -- 报名 type = 1报名界面 2报名信息界面 function ClubProtocolPhp:requestTiantiBaoming(localData,callback) local param = { app = getAppId(), gamename = localData.gamename, code = localData.code, phone = localData.phone, realname = localData.realname, type = localData.type, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_TIANTI_BAOMING_REG,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestTiantiBaomingReq",table.tostring(response)) if response.code==200 then local result = response.result if callback then -- callback(result.list) callback(result) if localData.type == 1 then showTooltip("报名成功") else showTooltip("修改信息成功") self.tiantiInfo = { phone = localData.phone, realname = localData.realname, } end self:dispatchEvent({name = GAME_EVENT.CLUB_TIANTI_BAOMING_REG, type = localData.type}) end else self:showError(Cmd.PHP_CLUB_TIANTI_BAOMING_REG,response) end end) end -- tianti -- 报名信息 function ClubProtocolPhp:requestTiantiBaomingInfo(callback) local param = { app = getAppId(), uid = app.user.loginInfo.uid, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_TIANTI_BAOMING_INFO,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestTiantiBaomingInfo",table.tostring(response)) if response.code==200 then local result = response.result self.tiantiInfo = {} self.tiantiInfo = { phone = result.phone, realname = result.realname, } if callback then callback(result) end else -- self:showError(Cmd.PHP_CLUB_TIANTI_BAOMING_INFO,response) end end) end -- tianti -- 排行榜 function ClubProtocolPhp:requestTiantiRank(callback, type) local param = { type = type, app = getAppId(), uid = app.user.loginInfo.uid, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_TIANTI_RANK,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() if cc.Application:getInstance():getTargetPlatform() == 0 then logD("ClubProtocolPhp:requestTiantiRank",table.tostring(response)) end if response.code==200 then local result = response.result if callback then callback(result) end else self:showError(Cmd.PHP_CLUB_TIANTI_RANK,response) end end) end -- tianti -- 游戏信息 function ClubProtocolPhp:requestTiantiGameInfo(callback) local param = { app = getAppId(), uid = app.user.loginInfo.uid, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_TIANTI_GAME_INFO,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestTiantiGameInfo",table.tostring(response)) if response.code==200 then local result = response.result if callback then callback(result) end else self:showError(Cmd.PHP_CLUB_TIANTI_GAME_INFO,response) end end) end --cest --取消小红点 function ClubProtocolPhp:requestSaveRankred(localData, callback) local param = { app = getAppId(), gid = localData.gid, lastday = localData.lastday, uid = app.user.loginInfo.uid, ruid = localData.ruid, } app.waitDialogManager:showWaitNetworkDialog("请求数据...") self:post(Cmd.PHP_CLUB_CEST_SAVE_RANKRED,param,function(response) app.waitDialogManager:closeWaitNetworkDialog() logD("ClubProtocolPhp:requestSaveRankred: <>",table.tostring(response)) if response.code==200 then if callback then callback() end else self:showError(Cmd.PHP_CLUB_CEST_SAVE_RANKRED,response) end end) end return ClubProtocolPhp