From 9e830c82b5e216158e1df92ebdf53960d8bad13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=AE=B6=E7=82=9C?= <2029049582@qq.com> Date: Fri, 11 Apr 2025 12:49:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E9=83=A8=E6=94=BE=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua_probject/base_project/Core/NetClient.lua | 6 +- lua_probject/base_project/Core/Queue.lua | 29 +- lua_probject/base_project/Core/bit.lua | 255 +- lua_probject/base_project/Core/string.lua | 59 +- lua_probject/base_project/FairyGUI.lua | 94 +- .../Game/Controller/GameController.lua | 141 +- .../Game/Controller/GroupMgrController.lua | 6 +- .../Game/Controller/LoddyController.lua | 144 +- .../Game/Controller/LoginController.lua | 6 +- .../Game/Controller/NewGroupController.lua | 860 +++--- .../Game/Controller/RoomController.lua | 2 +- .../base_project/Game/ControllerManager.lua | 4 +- .../base_project/Game/Data/TableBG.lua | 38 +- .../base_project/Game/ExtendHotupdate.lua | 2 +- .../base_project/Game/ExtendManager.lua | 2 +- .../Game/View/Common/BaseWindow.lua | 118 +- .../Game/View/Family/CreatePlayView.lua | 24 +- .../base_project/Game/View/FamilyView.lua | 10 +- .../Game/View/Lobby/CreateRoomView.lua | 2 +- .../Game/View/Lobby/JoinRoomView.lua | 43 +- .../Game/View/Lobby/LobbyPlayerInfoView.lua | 4 +- .../Game/View/Lobby/LobbyShopView.lua | 33 +- .../Game/View/Lobby/NoticeView.lua | 21 +- .../Game/View/Lobby/PhonePasswordView.lua | 40 +- .../base_project/Game/View/Lobby/RankView.lua | 171 +- .../Game/View/Lobby/UserEditView.lua | 24 +- .../base_project/Game/View/LobbyView.lua | 14 +- .../base_project/Game/View/LoginView.lua | 10 +- .../base_project/Game/View/MainView.lua | 22 +- .../Game/View/NewGroup/GroupInfoView.lua | 718 +++-- .../Game/View/NewGroup/GroupMainView.lua | 78 +- .../Game/View/NewGroup/GroupManagerView.lua | 71 +- .../NewGroup/MngView/GroupGameSettingView.lua | 6 +- .../MngView/GroupMemberFagLogView.lua | 152 +- .../MngView/GroupMemberOperateView.lua | 316 ++- .../NewGroup/MngView/GroupMngGameListView.lua | 2 +- .../MngView/GroupMngMemberListView.lua | 135 +- .../MngView/GroupMngMemberListView1.lua | 195 +- .../base_project/Game/View/PlayerInfoView.lua | 199 +- .../Game/View/PlayerInfoView_copy.lua | 2 +- .../base_project/Game/View/ViewUtil.lua | 6 +- .../base_project/Game/ViewManager.lua | 6 +- lua_probject/base_project/LuaDebug.lua | 909 +++---- lua_probject/base_project/LuaDebugjit.lua | 2414 ++++++++--------- lua_probject/base_project/Main.lua | 320 ++- lua_probject/base_project/debug/LuaDebug.lua | 909 +++---- .../base_project/debug/LuaDebugjit.lua | 2414 ++++++++--------- .../extend/majiang/100zhang/EXMainView.lua | 481 ++-- .../extend/majiang/100zhang/ExtendConfig.lua | 128 +- .../100zhang/MJPlayerSelfCardInfoView.lua | 109 +- .../majiang/changsha/EXClearingView.lua | 329 ++- .../extend/majiang/changsha/EXMainView.lua | 26 +- .../majiang/changsha/MJPlayerCardInfoView.lua | 28 +- .../changsha/MJPlayerSelfCardInfoView.lua | 44 +- .../extend/majiang/chaoshan/EXMainView.lua | 483 ++-- .../extend/majiang/chaoshan/ExtendConfig.lua | 128 +- .../chaoshan/MJPlayerSelfCardInfoView.lua | 109 +- .../extend/majiang/chaozhou/EXMainView.lua | 641 +++-- .../extend/majiang/chaozhou/ExtendConfig.lua | 128 +- .../chaozhou/MJPlayerSelfCardInfoView.lua | 109 +- .../extend/majiang/chaozhougui/EXMainView.lua | 641 +++-- .../majiang/chaozhougui/ExtendConfig.lua | 128 +- .../chaozhougui/MJPlayerSelfCardInfoView.lua | 109 +- .../extend/majiang/fuzhou/ExtendConfig.lua | 2 +- .../fuzhou/MJPlayerSelfCardInfoView.lua | 109 +- .../extend/majiang/gejiu/ExtendConfig.lua | 98 +- .../gejiu/MJPlayerSelfCardInfoView.lua | 109 +- .../extend/majiang/hongzhong/ExtendConfig.lua | 92 +- .../hongzhong/MJPlayerSelfCardInfoView.lua | 45 +- .../extend/majiang/jinxi/ExtendConfig.lua | 2 +- .../jinxi/MJPlayerSelfCardInfoView.lua | 109 +- .../majiang/lichuan/EXGameController.lua | 4 +- .../extend/majiang/lichuan/EXMainView.lua | 2 +- .../extend/majiang/lichuan/ExtendConfig.lua | 4 +- .../lichuan/MJPlayerSelfCardInfoView.lua | 4 +- .../extend/majiang/nancheng/ExtendConfig.lua | 3 +- .../nancheng/MJPlayerSelfCardInfoView.lua | 2 +- .../extend/majiang/qizhiba/EXMainView.lua | 678 +++-- .../extend/majiang/qizhiba/ExtendConfig.lua | 138 +- .../qizhiba/MJPlayerSelfCardInfoView.lua | 165 +- .../majiang/qizhiba/main/MJMainView.lua | 209 +- .../qizhiba/main/MJPlayerCardInfoView.lua | 100 +- .../qizhiba/main/MJPlayerSelfCardInfoView.lua | 4 +- .../extend/majiang/qizhiba/main/MJTableBG.lua | 38 +- .../extend/majiang/tuidaohu/EXMainView.lua | 479 ++-- .../extend/majiang/tuidaohu/ExtendConfig.lua | 128 +- .../tuidaohu/MJPlayerSelfCardInfoView.lua | 109 +- .../majiang/zhuanzhuan/ExtendConfig.lua | 92 +- .../zhuanzhuan/MJPlayerSelfCardInfoView.lua | 45 +- .../poker/chuntian/ChunTian_MainView.lua | 822 +++--- .../chuntian/ChunTian_PlayerBackView.lua | 39 +- .../ChunTian_PlayerSelfPokerInfoView.lua | 316 ++- .../chuntian/ChunTian_RightPanelView.lua | 27 +- .../extend/poker/chuntian/ExtendConfig.lua | 81 +- .../poker/mushi/MuShi_GameController.lua | 108 +- .../extend/poker/mushi/MuShi_MainView.lua | 826 +++--- .../poker/mushi/MuShi_PlayerBackView.lua | 117 +- .../mushi/MuShi_PlayerSelfPokerInfoView.lua | 96 +- .../extend/poker/runfast/ExtendConfig.lua | 2 +- .../extend/poker/runfast/RunFast_MainView.lua | 908 +++---- .../poker/runfast/RunFast_PlayerBackView.lua | 39 +- .../RunFast_PlayerSelfPokerInfoView.lua | 8 +- .../poker/runfast/RunFast_RightPanelView.lua | 27 +- .../extend/poker/sanqianfen/ExtendConfig.lua | 99 +- .../poker/sanqianfen/SanQianFen_MainView.lua | 1002 ++++--- .../sanqianfen/SanQianFen_PlayerBackView.lua | 74 +- .../SanQianFen_PlayerSelfPokerInfoView.lua | 622 +++-- .../sanqianfen/SanQianFen_RightPanelView.lua | 27 +- .../poker/shengsidu/ShengSiDu_MainView.lua | 745 +++-- .../shengsidu/ShengSiDu_PlayerBackView.lua | 39 +- .../ShengSiDu_PlayerSelfPokerInfoView.lua | 279 +- .../shengsidu/ShengSiDu_RightPanelView.lua | 27 +- .../twodoudizhu/TwoDouDiZhu_MainView.lua | 797 +++--- .../TwoDouDiZhu_PlayerBackView.lua | 68 +- .../TwoDouDiZhu_PlayerSelfPokerInfoView.lua | 315 ++- .../TwoDouDiZhu_RightPanelView.lua | 27 +- .../zipai/changdepaohuzi/EXGameController.lua | 482 ++-- .../zipai/changdepaohuzi/EXPlayBackView.lua | 77 +- .../changdepaohuzi/PlayerSelfCardInfoView.lua | 504 ++-- .../zipai/fulushou/EXGameController.lua | 566 ++-- .../extend/zipai/fulushou/EXMainView.lua | 591 ++-- .../extend/zipai/fulushou/EXPlayBackView.lua | 82 +- .../zipai/fulushou/PlayerSelfCardInfoView.lua | 539 ++-- .../zipai/hsrunbeard/EXGameController.lua | 484 ++-- .../extend/zipai/hsrunbeard/EXMainView.lua | 97 +- .../zipai/hsrunbeard/EXPlayBackView.lua | 8 +- .../hsrunbeard/PlayerSelfCardInfoView.lua | 506 ++-- .../zipai/runbeard/EXGameController.lua | 505 ++-- .../extend/zipai/runbeard/EXPlayBackView.lua | 77 +- .../zipai/runbeard/PlayerSelfCardInfoView.lua | 510 ++-- .../zipai/yueyangwaihuzi/EXGameController.lua | 546 ++-- .../zipai/yueyangwaihuzi/EXMainView.lua | 232 +- .../zipai/yueyangwaihuzi/EXPlayBackView.lua | 12 +- .../yueyangwaihuzi/PlayerSelfCardInfoView.lua | 565 ++-- .../yueyangwaihuzi_bak/EXGameController.lua | 546 ++-- .../zipai/yueyangwaihuzi_bak/EXMainView.lua | 232 +- .../yueyangwaihuzi_bak/EXPlayBackView.lua | 12 +- .../PlayerSelfCardInfoView.lua | 570 ++-- .../main_project/main/majiang/MJMainView.lua | 4 +- .../main/majiang/MJPlayerCardInfoView.lua | 10 +- .../main/majiang/MJPlayerSelfCardInfoView.lua | 2 +- .../main_project/main/majiang/MJTableBG.lua | 38 +- .../main_project/main/zipai/CardCheck.lua | 39 +- lua_probject/tolua_project/cjson/util.lua | 10 +- lua_probject/tolua_project/event.lua | 152 +- lua_probject/tolua_project/jit/bc.lua | 57 +- lua_probject/tolua_project/jit/dump.lua | 292 +- lua_probject/tolua_project/jit/v.lua | 21 +- lua_probject/tolua_project/jit/vmdef.lua | 701 ++--- lua_probject/tolua_project/jit/zone.lua | 9 +- lua_probject/tolua_project/lpeg/re.lua | 167 +- .../tolua_project/protobuf/decoder.lua | 41 +- .../tolua_project/protobuf/protobuf.lua | 196 +- .../tolua_project/protobuf/text_format.lua | 15 +- lua_probject/tolua_project/tolua.lua | 50 +- .../main_majiang/ui/main_majiang_fui.bytes | Bin 255267 -> 255274 bytes .../ui/Extend_Poker_RunFastNew_fui.bytes | Bin 126137 -> 126433 bytes 157 files changed, 16807 insertions(+), 17704 deletions(-) diff --git a/lua_probject/base_project/Core/NetClient.lua b/lua_probject/base_project/Core/NetClient.lua index 88b8aeb6..b630cc13 100644 --- a/lua_probject/base_project/Core/NetClient.lua +++ b/lua_probject/base_project/Core/NetClient.lua @@ -67,7 +67,7 @@ function NetClient.new(host, game, protocol) -- self.responseMap = {} self.onevent = event("onevent", false) self.onconnect = event("onconnect", false) - --print("222222222222222222222222222222222222222222 ",host," ",host," ",game," ",self.protocol) + ---- print("222222222222222222222222222222222222222222 ",host," ",host," ",game," ",self.protocol) self.c__netClient = LuaNetClient(host, game, self, self.protocol) self.c__netClient:SetCallBackListener(R.c__ondata) @@ -92,7 +92,7 @@ local NULL_JSON = "{}" --- send function R.send(self, cmd, data, callback) if (debug_print) then - print("send host:" .. self.host) + -- print("send host:" .. self.host) end if self.c__netClient == nil then return @@ -170,7 +170,7 @@ end ---c#网络层回调函数 function R.c__onconnect(self, code) if (debug_print) then - print("codeccccccccccccccccccccccccccccccccccccccc" .. code) + -- print("codeccccccccccccccccccccccccccccccccccccccc" .. code) end self.onconnect(code) end diff --git a/lua_probject/base_project/Core/Queue.lua b/lua_probject/base_project/Core/Queue.lua index 3f82dec6..eaae3f2f 100644 --- a/lua_probject/base_project/Core/Queue.lua +++ b/lua_probject/base_project/Core/Queue.lua @@ -2,8 +2,8 @@ Queue = {} function Queue.new(capacity) - local self = {} - setmetatable(self,{__index = Queue}) + local self = {} + setmetatable(self, { __index = Queue }) self.capacity = capacity self.queue = {} self.size_ = 0 @@ -20,12 +20,12 @@ function Queue:Enqueue(element) self.queue[self.rear] = element else local temp = (self.rear + 1) % self.capacity - --print("1111111111111111111====>>>>") - --print(temp) + ---- print("1111111111111111111====>>>>") + ---- print(temp) if temp == self.head then error("Error: capacity is full.") - ViewUtil.ErrorTip(10001,"Error: capacity is full.") - return + ViewUtil.ErrorTip(10001, "Error: capacity is full.") + return else self.rear = temp end @@ -33,12 +33,11 @@ function Queue:Enqueue(element) self.queue[self.rear] = element self.size_ = self.size_ + 1 end - end function Queue:Dequeue() if self:IsEmpty() then - ViewUtil.ErrorTip(10002,"Error: The Queue is empty.") + ViewUtil.ErrorTip(10002, "Error: The Queue is empty.") error("Error: The Queue is empty.") return end @@ -74,16 +73,16 @@ function Queue:dump() local first_flag = true while h ~= r do if first_flag == true then - str = "{"..self.queue[h] + str = "{" .. self.queue[h] h = (h + 1) % self.capacity first_flag = false else - str = str..","..self.queue[h] + str = str .. "," .. self.queue[h] h = (h + 1) % self.capacity end end - str = str..","..self.queue[r].."}" - if(debug_print) then - print(str) - end -end \ No newline at end of file + str = str .. "," .. self.queue[r] .. "}" + if (debug_print) then + -- print(str) + end +end diff --git a/lua_probject/base_project/Core/bit.lua b/lua_probject/base_project/Core/bit.lua index 2eb676d5..25eb8454 100644 --- a/lua_probject/base_project/Core/bit.lua +++ b/lua_probject/base_project/Core/bit.lua @@ -1,136 +1,135 @@ --[[ 位操作 ]] ---bit={data32={}} +--bit={data32={}} bit = bit or {} function bit.init32() bit.data32 = {} - for i=1,32 do - bit.data32[i]=2^(32-i) - end + for i = 1, 32 do + bit.data32[i] = 2 ^ (32 - i) + end end -bit.init32() - -function bit:d2b(arg) --bit:d2b - local tr={} - for i=1,32 do - if arg >= self.data32[i] then - tr[i]=1 - arg=arg-self.data32[i] - else - tr[i]=0 - end - end - return tr -end - -function bit:b2d(arg) --bit:b2d - local nr=0 - for i=1,32 do - if arg[i] ==1 then - nr=nr+2^(32-i) - end - end - return nr -end - -function bit:_xor(a,b) --bit:xor - local op1=self:d2b(a) - local op2=self:d2b(b) - local r={} - - for i=1,32 do - if op1[i]==op2[i] then - r[i]=0 - else - r[i]=1 - end - end - return self:b2d(r) -end - -function bit:_and(a,b) --bit:_and - local op1=self:d2b(a) - local op2=self:d2b(b) - local r={} - for i=1,32 do - if op1[i]==1 and op2[i]==1 then - r[i]=1 - else - r[i]=0 - end - end - return self:b2d(r) - -end - -function bit:_or(a,b) --bit:_or - local op1=self:d2b(a) - local op2=self:d2b(b) - local r={} - - for i=1,32 do - if op1[i]==1 or op2[i]==1 then - r[i]=1 - else - r[i]=0 - end - end - return self:b2d(r) -end - -function bit:_not(a) --bit:_not - local op1=self:d2b(a) - local r={} - - for i=1,32 do - if op1[i]==1 then - r[i]=0 - else - r[i]=1 - end - end - return self:b2d(r) -end - -function bit:_rshift(a,n) --bit:_rshift - local op1=self:d2b(a) - local r=self:d2b(0) - - if n < 32 and n > 0 then - for i=1,n do - for i=31,1,-1 do - op1[i+1]=op1[i] - end - op1[1]=0 - end - r=op1 - end - return self:b2d(r) -end - -function bit:_lshift(a,n) --bit:_lshift - local op1=self:d2b(a) - local r=self:d2b(0) - - if n < 32 and n > 0 then - for i=1,n do - for i=1,31 do - op1[i]=op1[i+1] - end - op1[32]=0 - end - r=op1 - end - return self:b2d(r) -end - - -function bit:print(ta) - local sr="" - for i=1,32 do - sr=sr..ta[i] - end - print(sr) -end \ No newline at end of file +bit.init32() + +function bit:d2b(arg) --bit:d2b + local tr = {} + for i = 1, 32 do + if arg >= self.data32[i] then + tr[i] = 1 + arg = arg - self.data32[i] + else + tr[i] = 0 + end + end + return tr +end + +function bit:b2d(arg) --bit:b2d + local nr = 0 + for i = 1, 32 do + if arg[i] == 1 then + nr = nr + 2 ^ (32 - i) + end + end + return nr +end + +function bit:_xor(a, b) --bit:xor + local op1 = self:d2b(a) + local op2 = self:d2b(b) + local r = {} + + for i = 1, 32 do + if op1[i] == op2[i] then + r[i] = 0 + else + r[i] = 1 + end + end + return self:b2d(r) +end + +function bit:_and(a, b) --bit:_and + local op1 = self:d2b(a) + local op2 = self:d2b(b) + local r = {} + + for i = 1, 32 do + if op1[i] == 1 and op2[i] == 1 then + r[i] = 1 + else + r[i] = 0 + end + end + return self:b2d(r) +end + +function bit:_or(a, b) --bit:_or + local op1 = self:d2b(a) + local op2 = self:d2b(b) + local r = {} + + for i = 1, 32 do + if op1[i] == 1 or op2[i] == 1 then + r[i] = 1 + else + r[i] = 0 + end + end + return self:b2d(r) +end + +function bit:_not(a) --bit:_not + local op1 = self:d2b(a) + local r = {} + + for i = 1, 32 do + if op1[i] == 1 then + r[i] = 0 + else + r[i] = 1 + end + end + return self:b2d(r) +end + +function bit:_rshift(a, n) --bit:_rshift + local op1 = self:d2b(a) + local r = self:d2b(0) + + if n < 32 and n > 0 then + for i = 1, n do + for i = 31, 1, -1 do + op1[i + 1] = op1[i] + end + op1[1] = 0 + end + r = op1 + end + return self:b2d(r) +end + +function bit:_lshift(a, n) --bit:_lshift + local op1 = self:d2b(a) + local r = self:d2b(0) + + if n < 32 and n > 0 then + for i = 1, n do + for i = 1, 31 do + op1[i] = op1[i + 1] + end + op1[32] = 0 + end + r = op1 + end + return self:b2d(r) +end + +function bit:print(ta) + local sr = "" + for i = 1, 32 do + sr = sr .. ta[i] + end + -- print(sr) +end diff --git a/lua_probject/base_project/Core/string.lua b/lua_probject/base_project/Core/string.lua index 8a5d1995..c7b7b3c6 100644 --- a/lua_probject/base_project/Core/string.lua +++ b/lua_probject/base_project/Core/string.lua @@ -1,5 +1,3 @@ - - string._htmlspecialchars_set = {} string._htmlspecialchars_set["&"] = "&" string._htmlspecialchars_set["\""] = """ @@ -10,7 +8,7 @@ string._htmlspecialchars_set[">"] = ">" --[[-- 将特殊字符转为 HTML 转义符 ~~~ lua -print(string.htmlspecialchars("")) +-- print(string.htmlspecialchars("")) -- 输出 <ABC> ~~~ @param string input 输入字符串 @@ -26,7 +24,7 @@ end --[[-- 将 HTML 转义符还原为特殊字符,功能与 string.htmlspecialchars() 正好相反 ~~~ lua -print(string.restorehtmlspecialchars("<ABC>")) +-- print(string.restorehtmlspecialchars("<ABC>")) -- 输出 ~~~ @param string input 输入字符串 @@ -42,7 +40,7 @@ end --[[-- 将字符串中的 \n 换行符转换为 HTML 标记 ~~~ lua -print(string.nl2br("Hello\nWorld")) +-- print(string.nl2br("Hello\nWorld")) -- 输出 -- Hello
World ~~~ @@ -56,7 +54,7 @@ end --[[-- 将字符串中的特殊字符和 \n 换行符转换为 HTML 转移符和标记 ~~~ lua -print(string.nl2br("\nWorld")) +-- print(string.nl2br("\nWorld")) -- 输出 -- <Hello>
World ~~~ @@ -88,10 +86,10 @@ local res = string.split(input, "-+-") function string.split(input, delimiter) input = tostring(input) delimiter = tostring(delimiter) - if (delimiter=='') then return false end - local pos,arr = 0, {} + if (delimiter == '') then return false end + local pos, arr = 0, {} -- for each divider found - for st,sp in function() return string.find(input, delimiter, pos, true) end do + for st, sp in function() return string.find(input, delimiter, pos, true) end do table.insert(arr, string.sub(input, pos, st - 1)) pos = sp + 1 end @@ -103,7 +101,7 @@ end 去除输入字符串头部的空白字符,返回结果 ~~~ lua local input = " ABC" -print(string.ltrim(input)) +-- print(string.ltrim(input)) -- 输出 ABC,输入字符串前面的两个空格被去掉了 ~~~ 空白字符包括: @@ -123,7 +121,7 @@ end 去除输入字符串尾部的空白字符,返回结果 ~~~ lua local input = "ABC " -print(string.ltrim(input)) +-- print(string.ltrim(input)) -- 输出 ABC,输入字符串最后的两个空格被去掉了 ~~~ @param string input 输入字符串 @@ -149,7 +147,7 @@ end 将字符串的第一个字符转为大写,返回结果 ~~~ lua local input = "hello" -print(string.ucfirst(input)) +-- print(string.ucfirst(input)) -- 输出 Hello ~~~ @param string input 输入字符串 @@ -167,7 +165,7 @@ end 将字符串转换为符合 URL 传递要求的格式,并返回转换结果 ~~~ lua local input = "hello world" -print(string.urlencode(input)) +-- print(string.urlencode(input)) -- 输出 -- hello%20world ~~~ @@ -188,7 +186,7 @@ end 将 URL 中的特殊字符还原,并返回结果 ~~~ lua local input = "hello%20world" -print(string.urldecode(input)) +-- print(string.urldecode(input)) -- 输出 -- hello world ~~~ @@ -197,9 +195,9 @@ print(string.urldecode(input)) @see string.urlencode ]] function string.urldecode(input) - input = string.gsub (input, "+", " ") - input = string.gsub (input, "%%(%x%x)", function(h) return string.char(checknumber(h,16)) end) - input = string.gsub (input, "\r\n", "\n") + input = string.gsub(input, "+", " ") + input = string.gsub(input, "%%(%x%x)", function(h) return string.char(checknumber(h, 16)) end) + input = string.gsub(input, "\r\n", "\n") return input end @@ -207,7 +205,7 @@ end 计算 UTF8 字符串的长度,每一个中文算一个字符 ~~~ lua local input = "你好World" -print(string.utf8len(input)) +-- print(string.utf8len(input)) -- 输出 7 ~~~ @param string input 输入字符串 @@ -219,7 +217,7 @@ function string.utf8len(input) local len = string.len(input) local left = len local cnt = 0 - local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc} + local arr = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc } while left ~= 0 do local tmp = string.byte(input, -left) local i = #arr @@ -243,15 +241,15 @@ end ]] function string.utf8sub(input, index, endIndex) if input == nil or type(input) ~= "string" then return nil end - if not endIndex then + if not endIndex then endIndex = index index = 1 end - local len = string.len(input) - local left = len - local cnt = 0 + local len = string.len(input) + local left = len + local cnt = 0 local head, tail = 0, 0 - local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc} + local arr = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc } while left ~= 0 do if cnt + 1 == index then head = len - left + 1 @@ -278,7 +276,7 @@ end --[[-- 将数值格式化为包含千分位分隔符的字符串 ~~~ lua -print(string.formatnumberthousands(1924235)) +-- print(string.formatnumberthousands(1924235)) -- 输出 1,924,235 ~~~ @param number num 数值 @@ -294,12 +292,11 @@ function string.formatnumberthousands(num) return formatted end - -function string.concat( ... ) +function string.concat(...) local str = {} - local tem = {...} - for _,v in ipairs(tem) do + local tem = { ... } + for _, v in ipairs(tem) do str[#str + 1] = v end - return table.concat(str , "") -end \ No newline at end of file + return table.concat(str, "") +end diff --git a/lua_probject/base_project/FairyGUI.lua b/lua_probject/base_project/FairyGUI.lua index 17cb674e..5f16e661 100644 --- a/lua_probject/base_project/FairyGUI.lua +++ b/lua_probject/base_project/FairyGUI.lua @@ -1,46 +1,46 @@ -EventContext = FairyGUI.EventContext -EventListener = FairyGUI.EventListener +EventContext = FairyGUI.EventContext +EventListener = FairyGUI.EventListener EventDispatcher = FairyGUI.EventDispatcher -InputEvent = FairyGUI.InputEvent -NTexture = FairyGUI.NTexture -Container = FairyGUI.Container -Image = FairyGUI.Image -Stage = FairyGUI.Stage -Controller = FairyGUI.Controller -GObject = FairyGUI.GObject -GGraph = FairyGUI.GGraph -GGroup = FairyGUI.GGroup -GImage = FairyGUI.GImage -GLoader = FairyGUI.GLoader -GMovieClip = FairyGUI.GMovieClip -TextFormat = FairyGUI.TextFormat -GTextField = FairyGUI.GTextField -GRichTextField = FairyGUI.GRichTextField -GTextInput = FairyGUI.GTextInput -GComponent = FairyGUI.GComponent -GList = FairyGUI.GList -GRoot = FairyGUI.GRoot -GLabel = FairyGUI.GLabel -GButton = FairyGUI.GButton -GComboBox = FairyGUI.GComboBox -GProgressBar = FairyGUI.GProgressBar -GSlider = FairyGUI.GSlider -PopupMenu = FairyGUI.PopupMenu -ScrollPane = FairyGUI.ScrollPane -Transition = FairyGUI.Transition -UIPackage = FairyGUI.UIPackage -Window = FairyGUI.Window -GObjectPool = FairyGUI.GObjectPool -Relations = FairyGUI.Relations -RelationType = FairyGUI.RelationType -UIPanel = FairyGUI.UIPanel -UIPainter = FairyGUI.UIPainter -TypingEffect = FairyGUI.TypingEffect -GTween = FairyGUI.GTween -GTweener = FairyGUI.GTweener -EaseType = FairyGUI.EaseType +InputEvent = FairyGUI.InputEvent +NTexture = FairyGUI.NTexture +Container = FairyGUI.Container +Image = FairyGUI.Image +Stage = FairyGUI.Stage +Controller = FairyGUI.Controller +GObject = FairyGUI.GObject +GGraph = FairyGUI.GGraph +GGroup = FairyGUI.GGroup +GImage = FairyGUI.GImage +GLoader = FairyGUI.GLoader +GMovieClip = FairyGUI.GMovieClip +TextFormat = FairyGUI.TextFormat +GTextField = FairyGUI.GTextField +GRichTextField = FairyGUI.GRichTextField +GTextInput = FairyGUI.GTextInput +GComponent = FairyGUI.GComponent +GList = FairyGUI.GList +GRoot = FairyGUI.GRoot +GLabel = FairyGUI.GLabel +GButton = FairyGUI.GButton +GComboBox = FairyGUI.GComboBox +GProgressBar = FairyGUI.GProgressBar +GSlider = FairyGUI.GSlider +PopupMenu = FairyGUI.PopupMenu +ScrollPane = FairyGUI.ScrollPane +Transition = FairyGUI.Transition +UIPackage = FairyGUI.UIPackage +Window = FairyGUI.Window +GObjectPool = FairyGUI.GObjectPool +Relations = FairyGUI.Relations +RelationType = FairyGUI.RelationType +UIPanel = FairyGUI.UIPanel +UIPainter = FairyGUI.UIPainter +TypingEffect = FairyGUI.TypingEffect +GTween = FairyGUI.GTween +GTweener = FairyGUI.GTweener +EaseType = FairyGUI.EaseType -fgui = {} +fgui = {} --[[ 用于继承FairyGUI的Window类,同时派生的Window类可以继续被继承。可以重写的方法有(与Window类里的同名方法含义完全相同) @@ -48,11 +48,11 @@ OnInit、DoHideAnimation、DoShowAnimation、OnShown、OnHide。 例子: MyWinClass = fgui.window_class() function MyWinClass:ctor() - print('MyWinClass-ctor') + -- print('MyWinClass-ctor') self.contentPane = UIPackage.CreateObject("Basics", "WindowA") end function MyWinClass:OnShown() - print('MyWinClass-onShown') + -- print('MyWinClass-onShown') end local win = MyWinClass.New() win:Show() @@ -74,7 +74,7 @@ function fgui.window_class(base) tolua.setpeer(ins, t) ins:SetLuaPeer(t) if t.ctor then - t.ctor(ins,...) + t.ctor(ins, ...) end return ins @@ -92,12 +92,12 @@ MyButton = fgui.extension_class(GButton) fgui.register_extension("ui://包名/我的按钮", MyButton) function MyButton:ctor() --当组件构建完成时此方法被调用 - print(self:GetChild("n1")) + -- print(self:GetChild("n1")) end --添加自定义的方法和字段 function MyButton:Test() - print('test') + -- print('test') end local get = tolua.initget(MyButton) @@ -133,7 +133,7 @@ function fgui.extension_class(base) o.Extend = function(ins) local t = {} setmetatable(t, o) - tolua.setpeer(ins,t) + tolua.setpeer(ins, t) return t end diff --git a/lua_probject/base_project/Game/Controller/GameController.lua b/lua_probject/base_project/Game/Controller/GameController.lua index b6399ee6..c6b805a0 100644 --- a/lua_probject/base_project/Game/Controller/GameController.lua +++ b/lua_probject/base_project/Game/Controller/GameController.lua @@ -17,14 +17,14 @@ GameEvent = { OnKicked = 'OnKicked', -- 更新玩家信息 OnUpdateInfo = 'OnUpdateInfo', - - --打开托管 - TupGuanOpen='TupGuanOpen', - --关闭托管 - TupGuanClose='TupGuanClose', - - --麻将修改牌大小 - MJModifySzie='MJModifySzie', + + --打开托管 + TupGuanOpen = 'TupGuanOpen', + --关闭托管 + TupGuanClose = 'TupGuanClose', + + --麻将修改牌大小 + MJModifySzie = 'MJModifySzie', } --- Base GameController @@ -40,7 +40,7 @@ GameController = { local M = GameController -setmetatable(M, {__index = IController}) +setmetatable(M, { __index = IController }) function M:init(name) self._name = name @@ -48,13 +48,13 @@ function M:init(name) self._cacheEvent = Queue.new(1000) self._eventmap = {} self._dispatcher = {} - self._eventmap[Protocol.FGMGR_EVT_UPDATE_RECONECT]=self.ResetConnect + self._eventmap[Protocol.FGMGR_EVT_UPDATE_RECONECT] = self.ResetConnect self._eventmap[Protocol.GAME_EVT_PLAYER_JOIN] = self.OnEventPlayerEnter self._eventmap[Protocol.GAME_EVT_PLAYER_NET_STATE] = self.OnEventOnlineState self._eventmap[Protocol.GAME_EVT_PLAYER_EXIT] = self.OnEventPlayerLeave self._eventmap[Protocol.GAME_EVT_READY] = self.OnEventPlayerReady - self._eventmap[Protocol.GAME_EVT_READY_AND_XIPAI] = self.OnEventPlayerXiPaiReady + self._eventmap[Protocol.GAME_EVT_READY_AND_XIPAI] = self.OnEventPlayerXiPaiReady self._eventmap[Protocol.GAME_EVT_EXIT_ROOM_DISMISS] = self.OnEventExitRoomDismiss self._eventmap[Protocol.GAME_EVT_DISMISS_ROOM] = self.OnEventDismissRoom @@ -66,13 +66,11 @@ function M:init(name) self._eventmap[Protocol.GAME_EVT_KICKED] = self.OnEventKicked self._eventmap[Protocol.GAME_EVT_UPDATE_PLAYERINFO] = self.OnEvtUpdateInfo - - self._eventmap[Protocol.GAME_EVT_READY_ENTRUST] = self.OnEvtOpenTupGTips - self._eventmap[Protocol.GAME_EVT_CANCEL_READY_ENTRUST] = self.OnEvtCloseTupGTips - - --self._eventmap[Protocol.GAME_AUTO_CARD] = self.OnEvtOpenGameHuTuoGtips - - + + self._eventmap[Protocol.GAME_EVT_READY_ENTRUST] = self.OnEvtOpenTupGTips + self._eventmap[Protocol.GAME_EVT_CANCEL_READY_ENTRUST] = self.OnEvtCloseTupGTips + + --self._eventmap[Protocol.GAME_AUTO_CARD] = self.OnEvtOpenGameHuTuoGtips end function DispatchEvent(_dispatcher, evt_name, ...) @@ -86,11 +84,10 @@ function M:AddEventListener(evt_name, func) self._dispatcher[evt_name] = func end - function M:ResetConnect() --- print("断线重连================") - --ControllerManager.OnConnect(SocketCode.TimeoutDisconnect) - ViewManager.refreshGameView() + -- -- print("断线重连================") + --ControllerManager.OnConnect(SocketCode.TimeoutDisconnect) + ViewManager.refreshGameView() end ----------------------请求------------------------------------ @@ -101,11 +98,12 @@ function M:PlayerReady() if not _client then return end + print("====================================1发送准备") _client:send(Protocol.GAME_READY) end function M:PlayerXiPai() - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if not _client then return end @@ -163,9 +161,9 @@ function M:AskDismissRoom() if not _client then return end - _client:send(Protocol.GAME_ASK_DISMISS_ROOM,nil,function (res) + _client:send(Protocol.GAME_ASK_DISMISS_ROOM, nil, function(res) if res.ReturnCode == 84 then - ViewUtil.ErrorTip(res.ReturnCode,"解散失败") + ViewUtil.ErrorTip(res.ReturnCode, "解散失败") end end) end) @@ -178,7 +176,7 @@ function M:DismissRoomVote(agree) if not _client then return end - -- print(agree) + -- -- print(agree) local _data = {} _data['result'] = agree _client:send(Protocol.GAME_DISMISS_ROOM_VOTE, _data) @@ -261,7 +259,7 @@ end -- 玩家进 function M:OnEventPlayerEnter(evt_data) - --print("进入房间++++++++++++++++++++++++++++++++++++++") + ---- print("进入房间++++++++++++++++++++++++++++++++++++++") self._cacheEvent:Enqueue( function() local p = self._room:NewPlayer() @@ -280,13 +278,12 @@ function M:OnEventPlayerEnter(evt_data) -- p.total_hp = evt_data["total_hp"] or 0 if evt_data['hp_info'] then p.cur_hp = evt_data.hp_info.cur_hp - -- p.total_hp = evt_data.hp_info.total_hp + -- p.total_hp = evt_data.hp_info.total_hp end p.self_user = _user p.line_state = 1 DataManager.CurrenRoom:AddPlayer(p) DispatchEvent(self._dispatcher, GameEvent.PlayerEnter, p) - end ) end @@ -325,47 +322,42 @@ function M:OnEventPlayerReady(evt_data) local pid = evt_data['aid'] local p = self._room:GetPlayerById(pid) p.ready = true - if evt_data.start~=nil then - if evt_data.start==1 then - p.isSendCardState=true - else - p.isSendCardState=false - end - - else - p.isSendCardState=false - end - + if evt_data.start ~= nil then + if evt_data.start == 1 then + p.isSendCardState = true + else + p.isSendCardState = false + end + else + p.isSendCardState = false + end + DispatchEvent(self._dispatcher, GameEvent.PlayerReady, p) end ) end - function M:OnEventPlayerXiPaiReady(evt_data) self._cacheEvent:Enqueue( function() local pid = evt_data['aid'] local p = self._room:GetPlayerById(pid) p.ready = true - if evt_data.start~=nil then - if evt_data.start==1 then - p.isSendCardState=true - else - p.isSendCardState=false - end - - else - p.isSendCardState=false - end + if evt_data.start ~= nil then + if evt_data.start == 1 then + p.isSendCardState = true + else + p.isSendCardState = false + end + else + p.isSendCardState = false + end DispatchEvent(self._dispatcher, GameEvent.PlayerReady, p) end ) end - - -- 聊天事件 function M:OnEventInteraction(evt_data) if self._room.ban_chat1 == false or self._room.ban_chat2 == false then @@ -377,7 +369,7 @@ function M:OnEventInteraction(evt_data) local parm = evt_data['parm'] DispatchEvent(self._dispatcher, GameEvent.Interaction, p, type1, parm) end - ) + ) end end @@ -396,7 +388,6 @@ function M:OnEventUpdateGPS(evt_data) ) end - -- 被踢出房间事件 function M:OnEventKicked() if ViewManager.GetCurrenView().dview_class == LobbyView then @@ -544,7 +535,7 @@ end function M:OnEnter() if (debug_print) then - print(self._name .. '进入Game控制器') + -- print(self._name .. '进入Game控制器') end self._room = DataManager.CurrenRoom local _client = ControllerManager.GameNetClinet @@ -555,14 +546,14 @@ end function M:OnExit() if (debug_print) then - print(self._name .. ' 离开Game控制器') + -- print(self._name .. ' 离开Game控制器') end ControllerManager.SetGameNetClient(nil) self._cacheEvent:Clear() end function M:__OnNetEvent(msg) - --print("Game消息ID===>>"..msg.Command) + ---- print("Game消息ID===>>"..msg.Command) local func = self._eventmap[msg.Command] if (func ~= nil) then func(self, msg.Data) @@ -586,42 +577,36 @@ function M:ReturnToRoom() end, self.tmpGroupID ) - end - function M:OnEvtOpenTupGTips(msg) - --print("显示托管倒计时=====================") - pt(msg) - local pid = msg['aid'] + ---- print("显示托管倒计时=====================") + pt(msg) + local pid = msg['aid'] local p = self._room:GetPlayerById(pid) - local t=msg['time'] - DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,true, t) + local t = msg['time'] + DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p, true, t) end - function M:OnEvtCloseTupGTips(msg) - --print("关闭托管倒计时=================") - --pt(msg) - local pid = msg['aid'] + ---- print("关闭托管倒计时=================") + --pt(msg) + local pid = msg['aid'] local p = self._room:GetPlayerById(pid) - local t=msg['time'] - DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,false, t) + local t = msg['time'] + DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p, false, t) end - -function M:DispatchEventTuoGuan(p,isShow,t) - DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,isShow, t) +function M:DispatchEventTuoGuan(p, isShow, t) + DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p, isShow, t) end - - function M:OnEvtOpenGameHuTuoGtips(isAuto) - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if not _client then return end local data = {} data.autoCard = isAuto _client:send(Protocol.GAME_AUTO_CARD, data) -end \ No newline at end of file +end diff --git a/lua_probject/base_project/Game/Controller/GroupMgrController.lua b/lua_probject/base_project/Game/Controller/GroupMgrController.lua index cedfd908..950bfcc7 100644 --- a/lua_probject/base_project/Game/Controller/GroupMgrController.lua +++ b/lua_probject/base_project/Game/Controller/GroupMgrController.lua @@ -72,7 +72,7 @@ function M:connect(host, groupId, callback) self._mgr_client:destroy() self._mgr_client = nil end - print("666666666666666666666666666 ", host) + -- print("666666666666666666666666666 ", host) local _mgr_client = NetClient.new(self.host, "mgr_group") self._mgr_client = _mgr_client _mgr_client:connect() @@ -186,7 +186,7 @@ end -- 更新玩法 function M:OnEvtUpdatePlay(evt_data) - --print("更新玩法=============》》》") + ---- print("更新玩法=============》》》") --pt(evt_data) local pid = evt_data.pid local group = DataManager.groups:get(self.groupId) @@ -354,7 +354,7 @@ function M:OnExit() end function M:__OnNetEvent(msg) - --print("消息ID===>>"..msg.Command) + ---- print("消息ID===>>"..msg.Command) local func = self._eventmap[msg.Command] if (func ~= nil) then func(self, msg.Data) end end diff --git a/lua_probject/base_project/Game/Controller/LoddyController.lua b/lua_probject/base_project/Game/Controller/LoddyController.lua index 29a8e875..3bc4c717 100644 --- a/lua_probject/base_project/Game/Controller/LoddyController.lua +++ b/lua_probject/base_project/Game/Controller/LoddyController.lua @@ -1,12 +1,11 @@ - LoddyController = {} local M = {} --- Create a new LoddyController function LoddyController.new() - setmetatable(M, {__index = IController}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = IController }) + local self = setmetatable({}, { __index = M }) self.baseType = LoddyController self.class = "Loddy" self.recordList = {} @@ -14,11 +13,11 @@ function LoddyController.new() end function M.OnEnter(self) - --print(vardump(self,"loddy controller enter")) + ---- print(vardump(self,"loddy controller enter")) end function M.OnExit(self) - --print(vardump(self,"loddy controller exit")) + ---- print(vardump(self,"loddy controller exit")) end local function __FillRoomData(s2croom) @@ -27,7 +26,7 @@ local function __FillRoomData(s2croom) extend:FillRoomData(s2croom) end -local function __ConntectGameServer(cmd,room, host, _data,callback) +local function __ConntectGameServer(cmd, room, host, _data, callback) -- local _data = {} _data["session"] = room.session local _game_client = NetClient.new(host, "game") @@ -35,7 +34,7 @@ local function __ConntectGameServer(cmd,room, host, _data,callback) ControllerManager.SetGameNetClient(_game_client) _game_client.onconnect:Add(function(code) if (code == SocketCode.Connect) then - _game_client:send(cmd, _data, function (response) + _game_client:send(cmd, _data, function(response) if (response.ReturnCode == 0) then _game_client.onconnect:Clear() _game_client.onconnect:Add(ControllerManager.OnConnect) @@ -44,39 +43,38 @@ local function __ConntectGameServer(cmd,room, host, _data,callback) end _game_client:destroy() if ControllerManager.GameNetClinet == _game_client then - ControllerManager.GameNetClinet =nil + ControllerManager.GameNetClinet = nil end callback(response) end) - else if ControllerManager.GameNetClinet == _game_client then - ControllerManager.GameNetClinet =nil + ControllerManager.GameNetClinet = nil end _game_client:destroy() - callback({ReturnCode = 101}) + callback({ ReturnCode = 101 }) end end) end function M:CreateRoom(game_id, _data, callback) - local _client = ControllerManager.WebClient - local data = {} - data.game_id = game_id + local _client = ControllerManager.WebClient + local data = {} + data.game_id = game_id data["platform"] = GetPlatform() data.config_data = _data -- local runtime = os.clock() _client:send(Protocol.WEB_CREATE_ROOM, data, function(res) - if ( res.ReturnCode == Table_Error_code.ERR_IN_ROOM or res.ReturnCode == Table_Error_code.ERR_CREATE_ROOM) then - self:JoinRoom("000000",callback) + if (res.ReturnCode == Table_Error_code.ERR_IN_ROOM or res.ReturnCode == Table_Error_code.ERR_CREATE_ROOM) then + self:JoinRoom("000000", callback) return end if (res.ReturnCode == 0) then local json = res.Data local game_info = json["game_info"] if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then - ExtendHotupdate.UpdateGame(game_info,function() + ExtendHotupdate.UpdateGame(game_info, function() res.ReturnCode = -2 callback(res) end) @@ -87,7 +85,7 @@ function M:CreateRoom(game_id, _data, callback) local server_ip = json["server_ip"] local server_port = json["server_port"] - local room = ExtendManager.GetExtendConfig(game_id):NewRoom() + local room = ExtendManager.GetExtendConfig(game_id):NewRoom() room.game_id = game_id room.room_id = room_id room.server_host = string.concat(server_ip, ":", server_port) @@ -99,12 +97,12 @@ function M:CreateRoom(game_id, _data, callback) local j_data = {} j_data["session"] = room.session if not DataManager.SelfUser.location then - DataManager.SelfUser.location = Location.new() + DataManager.SelfUser.location = Location.new() end j_data["pos"] = DataManager.SelfUser.location:Location2String() - -- game_net = - __ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data, function (response) + -- game_net = + __ConntectGameServer(Protocol.GAME_JOIN_ROOM, room, room.server_host, j_data, function(response) if (response.ReturnCode == 0) then -- game_net:clearEvent() local _s2croom = response.Data @@ -113,12 +111,12 @@ function M:CreateRoom(game_id, _data, callback) room.banker_seat = _s2croom["manor"] if _s2croom.createTime then room.create_time = _s2croom["createTime"] - end + end room.agent = _s2croom.agent == 1 and true or false local extend = ExtendManager.GetExtendConfig(room.game_id) extend:FillRoomData(_s2croom) ControllerManager.ChangeController(GameController) - -- print("create room:"..(os.clock()-runtime)) + -- -- print("create room:"..(os.clock()-runtime)) callback(response) return end @@ -126,13 +124,13 @@ function M:CreateRoom(game_id, _data, callback) callback(response) end) else - if callback then callback(res) end + if callback then callback(res) end end end) end local join_room_frame = 0 -function M:PublicJoinRoom(cmd,room_id,callback,group_id,group_layer) +function M:PublicJoinRoom(cmd, room_id, callback, group_id, group_layer) -- 同一帧不重复调用 local last_frame = join_room_frame join_room_frame = Time.frameCount @@ -147,12 +145,12 @@ function M:PublicJoinRoom(cmd,room_id,callback,group_id,group_layer) _data["floor"] = group_layer _data["platform"] = GetPlatform() local _client = ControllerManager.WebClient; - _client:send(cmd, _data, function( res) + _client:send(cmd, _data, function(res) if (res.ReturnCode == 0) then local json = res.Data local game_info = json["game_info"] if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then - ExtendHotupdate.UpdateGame(game_info,function() + ExtendHotupdate.UpdateGame(game_info, function() res.ReturnCode = -2 callback(res) end) @@ -162,7 +160,7 @@ function M:PublicJoinRoom(cmd,room_id,callback,group_id,group_layer) local server_ip = json["server_ip"] local server_port = json["server_port"] - local room = ExtendManager.GetExtendConfig(game_id):NewRoom() + local room = ExtendManager.GetExtendConfig(game_id):NewRoom() room.lev = json["lev"] -- 自己在当前房间所在圈子的职位,1盟主,2管理员,3用户,非圈子房间就是3 room.room_id = json["room_id"] room.game_id = game_id @@ -178,44 +176,43 @@ function M:PublicJoinRoom(cmd,room_id,callback,group_id,group_layer) DataManager.CurrenRoom = room local j_data = {} if not DataManager.SelfUser.location then - DataManager.SelfUser.location = Location.new() + DataManager.SelfUser.location = Location.new() end j_data["pos"] = DataManager.SelfUser.location:Location2String() -- local game_net = nil - --print(vardump(room)) - -- game_net = - __ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data,function ( res1) - if (res1.ReturnCode ~= 0 ) then + ---- print(vardump(room)) + -- game_net = + __ConntectGameServer(Protocol.GAME_JOIN_ROOM, room, room.server_host, j_data, function(res1) + if (res1.ReturnCode ~= 0) then if (callback) then callback(res1) end else local _s2croom = res1.Data room.owner_id = _s2croom["owner"] if _s2croom.createTime then room.create_time = _s2croom["createTime"] - end + end if _s2croom.manor then room.banker_seat = _s2croom.manor end room.agent = _s2croom.agent == 1 and true or false -- ControllerManager.SetGameNetClient(game_net) - local extend = ExtendManager.GetExtendConfig(room.game_id) + local extend = ExtendManager.GetExtendConfig(room.game_id) extend:FillRoomData(_s2croom) ControllerManager.ChangeController(GameController) if callback then callback(res1) end end - end) + end) -- callback(res) else - if callback then callback(res) end + if callback then callback(res) end end end) end -function M:JoinRoom(room_id,callback,group_id,group_layer) - self:PublicJoinRoom(Protocol.WEB_JOIN_ROOM,room_id,callback,group_id,group_layer) +function M:JoinRoom(room_id, callback, group_id, group_layer) + self:PublicJoinRoom(Protocol.WEB_JOIN_ROOM, room_id, callback, group_id, group_layer) end - function M:ResetJionRoom(callback) local _game = ControllerManager.GetController(GameController) local o_room = DataManager.CurrenRoom @@ -224,7 +221,7 @@ function M:ResetJionRoom(callback) DataManager.SelfUser.location = Location.new() end j_data["pos"] = DataManager.SelfUser.location:Location2String() - local room = ExtendManager.GetExtendConfig(o_room.game_id):NewRoom() + local room = ExtendManager.GetExtendConfig(o_room.game_id):NewRoom() room.lev = o_room.lev room.room_id = o_room.room_id room.game_id = o_room.game_id @@ -241,14 +238,14 @@ function M:ResetJionRoom(callback) room.create_time = o_room.create_time room:SetReloadStatus(true) DataManager.CurrenRoom = room - __ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data,function ( res1) + __ConntectGameServer(Protocol.GAME_JOIN_ROOM, room, room.server_host, j_data, function(res1) room:SetReloadStatus(false) - if (res1.ReturnCode ~= 0 ) then + if (res1.ReturnCode ~= 0) then if (callback) then callback(res1) end else printlog("ResetJionRoom==>>>") pt(res1) - ControllerManager.enterPlayerData=res1.Data.tableInfo.playerData + ControllerManager.enterPlayerData = res1.Data.tableInfo.playerData local _s2croom = res1.Data local extend = ExtendManager.GetExtendConfig(room.game_id) extend:FillRoomData(_s2croom) @@ -259,8 +256,8 @@ function M:ResetJionRoom(callback) end function M:UpdatePlayerInfo(callback) - local _client = ControllerManager.WebClient - _client:send(Protocol.WEB_UPDATE_INFO, nil, function (res) + local _client = ControllerManager.WebClient + _client:send(Protocol.WEB_UPDATE_INFO, nil, function(res) if res.ReturnCode == 0 then DataManager.SelfUser.diamo = res.Data.diamo DataManager.SelfUser.invited = res.Data.invitation @@ -272,19 +269,19 @@ function M:UpdatePlayerInfo(callback) end) end -function M:UpdateNotice(id,callback) - local _client = ControllerManager.WebClient - local _data = {} +function M:UpdateNotice(id, callback) + local _client = ControllerManager.WebClient + local _data = {} _data.id = id - _client:send(Protocol.WEB_UPDATE_NOTICE, _data, function (res) - --print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ",res) + _client:send(Protocol.WEB_UPDATE_NOTICE, _data, function(res) + ---- print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ",res) --pt(res) if res.ReturnCode == 0 and #res.Data.notice_list > 0 then callback(true, res.Data) else callback(false) end - end) + end) end function M:RequestRecordList(callback, roomid) @@ -293,15 +290,15 @@ function M:RequestRecordList(callback, roomid) _data["platform"] = GetPlatform() local proto if not roomid then - proto = Protocol.WEB_GET_MILITARY - else + proto = Protocol.WEB_GET_MILITARY + else proto = Protocol.WEB_GET_MILITARY_BY_ROOMID _data.roomId = roomid end - _client:send(proto, _data, function (res) + _client:send(proto, _data, function(res) self.recordList = nil - -- print(vardump(res)) - if (res.ReturnCode == 0 or res.ReturnCode == 19 ) then + -- -- print(vardump(res)) + if (res.ReturnCode == 0 or res.ReturnCode == 19) then --self:RequestRankList(callback) self.recordList = {} if res.ReturnCode == 19 then return end @@ -335,8 +332,8 @@ function M:RequestRecordList(callback, roomid) end local round_count = record_list_item["round"] - for j = 1,round_count do - local round_score_str = record_list_item["round_"..j] + for j = 1, round_count do + local round_score_str = record_list_item["round_" .. j] local m_round_game = MGameTimes.new() if round_score_str then local round_score_item = json.decode(round_score_str) @@ -359,50 +356,45 @@ function M:RequestRecordList(callback, roomid) end) end - -function M:RequestPlayBack(_data,callback,game_info) +function M:RequestPlayBack(_data, callback, game_info) if game_info and ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then - ExtendHotupdate.UpdateGame(game_info,function() - self:RequestPlayBack(_data,callback) + ExtendHotupdate.UpdateGame(game_info, function() + self:RequestPlayBack(_data, callback) end) return else local _client = ControllerManager.WebClient - _client:send(Protocol.WEB_GET_PLAY_BACK , _data , function (res) + _client:send(Protocol.WEB_GET_PLAY_BACK, _data, function(res) if res.ReturnCode == 0 then local data = json.decode(res.Data.playback) local cmdList = data.cmdList local info = data.info local extend = ExtendManager.GetExtendConfig(info.game_id) - local room = extend:NewRoom() + local room = extend:NewRoom() room.game_id = info.game_id DataManager.CurrenRoom = room extend:FillPlayBackData(data) if not room.self_player then room.self_player = room:GetPlayerBySeat(1) end - callback(res.ReturnCode,data) + callback(res.ReturnCode, data) else - callback(res.ReturnCode,nil) + callback(res.ReturnCode, nil) end - end) end end - - --获取手机验证码 -function M:GetPhoneCode(phone,callback) +function M:GetPhoneCode(phone, callback) local _client = ControllerManager.WebClient local _data = {} - _data["phone"]=phone + _data["phone"] = phone _client:send(Protocol.WEB_GET_VERIFCATION_CODE, _data, function(res) callback(res) end) end - function M:GetUserInfo(callback) local _client = ControllerManager.WebClient _client:send(Protocol.WEB_GET_USER_INFO, nil, function(res) @@ -419,7 +411,7 @@ function M:GetUserInfo(callback) end) end -function M:UpdateUserInfo(_data,callback) +function M:UpdateUserInfo(_data, callback) local _client = ControllerManager.WebClient _client:send(Protocol.WEB_UPDATE_USER_INFO, _data, function(res) callback(res) @@ -427,11 +419,11 @@ function M:UpdateUserInfo(_data,callback) end -- 设置被邀请开关 -function M:SetInvited(on, callback) +function M:SetInvited(on, callback) local _client = ControllerManager.WebClient local _data = {} _data["invitation"] = on _client:send(Protocol.WEB_SET_GROUP_INVITATED, _data, function(res) callback(res) end) -end \ No newline at end of file +end diff --git a/lua_probject/base_project/Game/Controller/LoginController.lua b/lua_probject/base_project/Game/Controller/LoginController.lua index c277bfce..b6a64562 100644 --- a/lua_probject/base_project/Game/Controller/LoginController.lua +++ b/lua_probject/base_project/Game/Controller/LoginController.lua @@ -61,7 +61,7 @@ local function __Login(cmd, _data, callBack) end _client:setSession(data["session_id"] .. "," .. data["token"]) - print("11111111111111111111111111111111") + -- print("11111111111111111111111111111111") pt(data) ControllerManager.GroupClient = NetClient.new(data.groupWeb, "web_group", ConnectionProtocol.Web) ControllerManager.GroupClient:setSession((data["session_id"] .. "," .. data["token"])) @@ -129,11 +129,11 @@ function M:QuickLogin(session_id, callback) end function M.OnEnter(self) - --print("login controller enter") + ---- print("login controller enter") end function M.OnExit(self) - --print("login controller exit") + ---- print("login controller exit") end --字符串类json格式转化为表 diff --git a/lua_probject/base_project/Game/Controller/NewGroupController.lua b/lua_probject/base_project/Game/Controller/NewGroupController.lua index 345dcdae..81fd7e6d 100644 --- a/lua_probject/base_project/Game/Controller/NewGroupController.lua +++ b/lua_probject/base_project/Game/Controller/NewGroupController.lua @@ -1,4 +1,3 @@ - NewGroupController = {} local M = {} @@ -7,14 +6,13 @@ local GroupMgrController = import(".GroupMgrController") --- Create a new NewGroupController function NewGroupController.new() - setmetatable(M, {__index = IController}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = IController }) + local self = setmetatable({}, { __index = M }) self.baseType = NewGroupController self.class = "NewGroup" return self end - --获取圈列表 function M:FG_GroupList(callback) local _client = ControllerManager.GroupClient @@ -27,7 +25,7 @@ function M:FG_GroupList(callback) local r_groups = res.Data.groups local l_groups = DataManager.groups l_groups:clear() - for i=1,#r_groups do + for i = 1, #r_groups do local tem = r_groups[i] local group = GroupData.new() group.id = tem.id @@ -53,10 +51,10 @@ end --创建圈 function M:FG_CreateGroup(name, pay_type, type, callback) local _client = ControllerManager.GroupClient - local data = {} - data.name= name + local data = {} + data.name = name data.pay_type = pay_type - data.type = type + data.type = type _client:send(Protocol.WEB_FG_CREATE_GROUP, data, function(res) if res.ReturnCode == 0 then local l_groups = DataManager.groups @@ -78,10 +76,10 @@ function M:FG_CreateGroup(name, pay_type, type, callback) end --删除圈 -function M:FG_RemoveGroup(id,callback) +function M:FG_RemoveGroup(id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = id + local data = {} + data.id = id _client:send(Protocol.WEB_FG_REMOVE_GROUP, data, function(res) if res.ReturnCode == 0 then local l_groups = DataManager.groups @@ -94,8 +92,8 @@ end --退出圈子 function M:FG_ExitGroup(group_id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id + local data = {} + data.id = group_id _client:send(Protocol.WEB_FG_EXIT_GROUP, data, function(res) if res.ReturnCode == 0 then local l_groups = DataManager.groups @@ -106,21 +104,21 @@ function M:FG_ExitGroup(group_id, callback) end --加入圈 -function M:FG_JoinGroup(id,callback) +function M:FG_JoinGroup(id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = id + local data = {} + data.id = id _client:send(Protocol.WEB_FG_JOIN_GROUP, data, function(res) callback(res) end) end --置顶圈 -function M:FG_TopGroup(group_id,top,callback) +function M:FG_TopGroup(group_id, top, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.top = top + local data = {} + data.id = group_id + data.top = top _client:send(Protocol.WEB_FG_GROUP_TOP, data, function(res) if res.ReturnCode == 0 then local l_groups = DataManager.groups @@ -131,7 +129,8 @@ function M:FG_TopGroup(group_id,top,callback) end) end -function M:FG_UpdateGroupInfo(id, name, notice, ban, dissolve_opt, kick_opt, apply, ban_chat1, ban_chat2, option, showNum, callback) +function M:FG_UpdateGroupInfo(id, name, notice, ban, dissolve_opt, kick_opt, apply, ban_chat1, ban_chat2, option, showNum, + callback) local _client = ControllerManager.GroupClient local data = {} data.id = id @@ -151,22 +150,22 @@ function M:FG_UpdateGroupInfo(id, name, notice, ban, dissolve_opt, kick_opt, app end --圈邀请列表 -function M:FG_GroupJoins(id,callback) +function M:FG_GroupJoins(id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = id + local data = {} + data.id = id _client:send(Protocol.WEB_FG_GROUP_JOINS, data, function(res) callback(res) end) end --圈审核玩家加入 -function M:FG_GroupVerifyJoin(id,tagId,allow,callback) +function M:FG_GroupVerifyJoin(id, tagId, allow, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = id - data.tagId = tagId - data.allow = allow + local data = {} + data.id = id + data.tagId = tagId + data.allow = allow _client:send(Protocol.WEB_FG_GROUP_VERIFY_JOIN, data, function(res) callback(res) end) @@ -174,158 +173,149 @@ end --圈玩家列表 function M:FG_GroupMembers(group_id, limit, num, minus_only, sort_type, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.limit = limit + data.num = num data.minus_only = minus_only - data.type = sort_type - --print(debug.traceback()) + data.type = sort_type + ---- print(debug.traceback()) _client:send(Protocol.WEB_FG_GROUP_MEMBERS, data, function(res) - --print("查询圈子玩家列表============") + ---- print("查询圈子玩家列表============") --pt(res) if res.ReturnCode == 0 then local group = DataManager.groups:get(group_id) local members = res.Data.members - for i=1,#members do + for i = 1, #members do local m = members[i] group:addMember(m) end end callback(res) - end) end - function M:FG_GroupMembers11(group_id, limit, num, minus_only, sort_type, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num - data.minus_only = minus_only - data.type = sort_type - self.currentGroupMembersData=data - self.currentGroupMembersCallBack=callback - --print(debug.traceback()) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.limit = limit + data.num = num + data.minus_only = minus_only + data.type = sort_type + self.currentGroupMembersData = data + self.currentGroupMembersCallBack = callback + ---- print(debug.traceback()) _client:send(Protocol.WEB_FG_GROUP_MEMBERS, data, function(res) - --print("查询圈子玩家列表============") + ---- print("查询圈子玩家列表============") --pt(res) if res.ReturnCode == 0 then local group = DataManager.groups:get(group_id) local members = res.Data.members - for i=1,#members do + for i = 1, #members do local m = members[i] group:addMember(m) end end callback(res) - end) end -function M:FG_GroupMembers12(group_id, limit, num,type,online, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num - data.online = online - data.type = type +function M:FG_GroupMembers12(group_id, limit, num, type, online, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.limit = limit + data.num = num + data.online = online + data.type = type --data.minus_only = minus_only --data.type = sort_type - self.currentGroupMembersData=data - self.currentGroupMembersCallBack=callback - --print(debug.traceback()) + self.currentGroupMembersData = data + self.currentGroupMembersCallBack = callback + ---- print(debug.traceback()) _client:send(Protocol.WEB_FG_GROUP_MEMBERS1, data, function(res) - --print("查询圈子玩家列表============") + ---- print("查询圈子玩家列表============") --pt(res) if res.ReturnCode == 0 then local group = DataManager.groups:get(group_id) local members = res.Data.members - for i=1,#members do + for i = 1, #members do local m = members[i] group:addMember(m) end end callback(res) - end) end -function M:FG_GroupTiChu(group_id,limit, num,callback) +function M:FG_GroupTiChu(group_id, limit, num, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num - _client:send(Protocol.WEB_FG_GROUP_TICHU, data, function(res) + local data = {} + data.id = group_id + data.limit = limit + data.num = num + _client:send(Protocol.WEB_FG_GROUP_TICHU, data, function(res) if res.ReturnCode == 0 then - + end - callback(res) + callback(res) end) end - function M:SendGetGroupMembersInfo() local _client = ControllerManager.GroupClient if self.currentGroupMembersData and self.currentGroupMembersCallBack then - _client:send(Protocol.WEB_FG_GROUP_MEMBERS1, self.currentGroupMembersData, function(res) - --print("查询圈子玩家列表============") + _client:send(Protocol.WEB_FG_GROUP_MEMBERS1, self.currentGroupMembersData, function(res) + ---- print("查询圈子玩家列表============") --pt(res) if res.ReturnCode == 0 then local group = DataManager.groups:get(self.currentGroupMembersData.id) local members = res.Data.members - for i=1,#members do + for i = 1, #members do local m = members[i] group:addMember(m) end end self.currentGroupMembersCallBack(res) - end) end - end -- 查询成员 -function M:FG_FindMember(group_id, member_id, callback, tag_name,tag_type) +function M:FG_FindMember(group_id, member_id, callback, tag_name, tag_type) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = member_id - data.tagName = tag_name - data.tagType = tag_type - _client:send(Protocol.WEB_FG_FIND_MEMBER, data, function(res) - --print("查询圈子单个玩家列表============") + local data = {} + data.id = group_id + data.tagId = member_id + data.tagName = tag_name + data.tagType = tag_type + _client:send(Protocol.WEB_FG_FIND_MEMBER, data, function(res) + ---- print("查询圈子单个玩家列表============") --pt(res) - if res.ReturnCode == 0 then - local group = DataManager.groups:get(group_id) - local m = res.Data - if group.lev == 3 then - if res.Data.parentId == DataManager.SelfUser.account_id then - group:addMember(m) - end - end - end + if res.ReturnCode == 0 then + local group = DataManager.groups:get(group_id) + local m = res.Data + if group.lev == 3 then + if res.Data.parentId == DataManager.SelfUser.account_id then + group:addMember(m) + end + end + end callback(res) end) end - - -- 强制提取 function M:FG_TakeHp1(group_id, tagId, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = tagId + local data = {} + data.id = group_id + data.tagId = tagId - _client:send(Protocol.WEB_FG_TAKE_HP, data, function(res) - --print("查询圈子单个玩家列表============") + _client:send(Protocol.WEB_FG_TAKE_HP, data, function(res) + ---- print("查询圈子单个玩家列表============") --pt(res) callback(res) end) @@ -337,7 +327,7 @@ function M:FG_DeployMember(group_id, member_id, partner_id, callback) local data = {} data.id = group_id data.tagId = member_id - data.parId = partner_id + data.parId = partner_id _client:send(Protocol.WEB_FG_DEPLOY_MEMBER, data, function(res) callback(res) end) @@ -349,19 +339,19 @@ function M:FG_MovePartner(group_id, member_id, partner_id, callback) local data = {} data.id = group_id data.tagId = member_id - data.parId = partner_id + data.parId = partner_id _client:send(Protocol.WEB_FG_MOVE_PARTNER, data, function(res) callback(res) end) end -- 获取合伙人列表(合伙人管理) -function M:FG_GetPartnerList(group_id, simple_all, limit, num ,callback,tagId) +function M:FG_GetPartnerList(group_id, simple_all, limit, num, callback, tagId) local _client = ControllerManager.GroupClient local data = {} data.id = group_id data.simple_all = simple_all - if tagId then + if tagId then data.tagId = tagId end if simple_all == 0 then @@ -387,14 +377,13 @@ function M:FG_QueryPartnerList(group_id, query_id, query_nick, callback) end) end -function M:FG_GetMemberStat(group_id,query_id,partner_id,limit,num,time_type,begin_time,end_time,callback) - - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.qid = query_id +function M:FG_GetMemberStat(group_id, query_id, partner_id, limit, num, time_type, begin_time, end_time, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.qid = query_id data.partner_id = partner_id - data.tt = time_type + data.tt = time_type if time_type == 3 then data.bt = begin_time data.et = end_time @@ -406,13 +395,11 @@ function M:FG_GetMemberStat(group_id,query_id,partner_id,limit,num,time_type,beg end) end - -function M:FG_GetPartnerStat(group_id,limit,num,time_type,begin_time,end_time,callback) - +function M:FG_GetPartnerStat(group_id, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tt = time_type + local data = {} + data.id = group_id + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time @@ -424,12 +411,11 @@ function M:FG_GetPartnerStat(group_id,limit,num,time_type,begin_time,end_time,ca end) end -function M:FG_GetZuanShiStat(group_id,limit,num,time_type,begin_time,end_time,callback) - +function M:FG_GetZuanShiStat(group_id, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tt = time_type + local data = {} + data.id = group_id + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time @@ -442,38 +428,38 @@ function M:FG_GetZuanShiStat(group_id,limit,num,time_type,begin_time,end_time,ca end -- WEB_FG_FIND_PARTNER_STAT -function M:FG_FindPartnerStat(group_id,member_id,limit,num,time_type,begin_time,end_time,callback) +function M:FG_FindPartnerStat(group_id, member_id, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = member_id - data.limit = limit - data.num = num - data.tt = time_type - + local data = {} + data.id = group_id + data.tagId = member_id + data.limit = limit + data.num = num + data.tt = time_type + if time_type == 0 then data.bt = begin_time data.et = end_time end - _client:send(Protocol.WEB_FG_FIND_PARTNER_STAT, data, function(res) + _client:send(Protocol.WEB_FG_FIND_PARTNER_STAT, data, function(res) callback(res) end) end -function M:FG_FindZuanShiStat(group_id,member_id,limit,num,time_type,begin_time,end_time,callback) +function M:FG_FindZuanShiStat(group_id, member_id, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = member_id - data.limit = limit - data.num = num - data.tt = time_type - + local data = {} + data.id = group_id + data.tagId = member_id + data.limit = limit + data.num = num + data.tt = time_type + if time_type == 0 then data.bt = begin_time data.et = end_time end - _client:send(Protocol.WEB_FG_FIND_COST_COUNT_STAT, data, function(res) + _client:send(Protocol.WEB_FG_FIND_COST_COUNT_STAT, data, function(res) callback(res) end) end @@ -481,52 +467,53 @@ end --find_partner_stat_member -- WEB_FG_FIND_PARTNER_STAT -function M:FG_FindPartnerStatMember(group_id,uid,root_uid,member_id,limit,num,time_type,begin_time,end_time,callback) +function M:FG_FindPartnerStatMember(group_id, uid, root_uid, member_id, limit, num, time_type, begin_time, end_time, + callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = member_id - data.limit = limit - data.num = num - data.id = group_id - data.tt = time_type - data.uid = uid + local data = {} + data.id = group_id + data.tagId = member_id + data.limit = limit + data.num = num + data.id = group_id + data.tt = time_type + data.uid = uid data.root_uid = 0 if time_type == 0 then data.bt = begin_time data.et = end_time end - _client:send(Protocol.WEB_FG_FIND_PARTNER_STAT_Member, data, function(res) + _client:send(Protocol.WEB_FG_FIND_PARTNER_STAT_Member, data, function(res) callback(res) end) end -function M:FG_FindPartnerZuanShiMember(group_id,uid,root_uid,member_id,limit,num,time_type,begin_time,end_time,callback) +function M:FG_FindPartnerZuanShiMember(group_id, uid, root_uid, member_id, limit, num, time_type, begin_time, end_time, + callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = member_id - data.limit = limit - data.num = num - data.id = group_id - data.tt = time_type - data.uid = uid + local data = {} + data.id = group_id + data.tagId = member_id + data.limit = limit + data.num = num + data.id = group_id + data.tt = time_type + data.uid = uid data.root_uid = 0 if time_type == 0 then data.bt = begin_time data.et = end_time end - _client:send(Protocol.WEB_FG_FIND_PARTNER_COST_COUNT_Member, data, function(res) + _client:send(Protocol.WEB_FG_FIND_PARTNER_COST_COUNT_Member, data, function(res) callback(res) end) end -function M:FG_GetXingYunStat(group_id,limit,num,time_type,begin_time,end_time,callback) - +function M:FG_GetXingYunStat(group_id, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tt = time_type + local data = {} + data.id = group_id + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time @@ -538,117 +525,113 @@ function M:FG_GetXingYunStat(group_id,limit,num,time_type,begin_time,end_time,ca end) end -function M:FG_GetMembersCount(group_id,callback) +function M:FG_GetMembersCount(group_id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - + local data = {} + data.id = group_id + _client:send(Protocol.WEB_FG_GET_MEMBERS_COUNT, data, function(res) callback(res) end) end -function M:FG_GetPartnerStatMember(group_id,uid,root_uid,limit,num,time_type,begin_time,end_time,callback) - +function M:FG_GetPartnerStatMember(group_id, uid, root_uid, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} + local data = {} - data.id = group_id - data.uid = uid - data.limit = limit - data.num = num + data.id = group_id + data.uid = uid + data.limit = limit + data.num = num data.root_uid = root_uid - data.tt = time_type + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time end - + _client:send(Protocol.WEB_FG_GET_PARTNER_STAT_MEMBER, data, function(res) callback(res) end) end -function M:FG_GetDirectMemberStat(group_id,uid,root_uid,limit,num,time_type,begin_time,end_time,callback) +function M:FG_GetDirectMemberStat(group_id, uid, root_uid, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.uid = uid - data.limit = limit - data.num = num + local data = {} + data.id = group_id + data.uid = uid + data.limit = limit + data.num = num data.root_uid = root_uid - data.tt = time_type + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time - end + end _client:send(Protocol.WEB_FG_GET_DIRECT_MEMBER_STAT, data, function(res) callback(res) end) end -function M:FG_GetPartnerZuanShiMember(group_id,uid,root_uid,limit,num,time_type,begin_time,end_time,callback) - +function M:FG_GetPartnerZuanShiMember(group_id, uid, root_uid, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} + local data = {} - data.id = group_id - data.uid = uid - data.limit = limit - data.num = num + data.id = group_id + data.uid = uid + data.limit = limit + data.num = num data.root_uid = root_uid - data.tt = time_type + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time end - + _client:send(Protocol.WEB_FG_GET_PARTNER_COST_COUNT, data, function(res) callback(res) end) end -function M:FG_GetDirectZuanShiStat(group_id,uid,root_uid,limit,num,time_type,begin_time,end_time,callback) +function M:FG_GetDirectZuanShiStat(group_id, uid, root_uid, limit, num, time_type, begin_time, end_time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.uid = uid - data.limit = limit - data.num = num + local data = {} + data.id = group_id + data.uid = uid + data.limit = limit + data.num = num data.root_uid = root_uid - data.tt = time_type + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time - end + end _client:send(Protocol.WEB_FG_GET_DIRECT_COST_COUNT, data, function(res) callback(res) end) end -function M:FG_GetPartnerStatPlay(group_id,uid,parent_id,limit,num,time_type,begin_time,end_time,callback) +function M:FG_GetPartnerStatPlay(group_id, uid, parent_id, limit, num, time_type, begin_time, end_time, callback) + local _client = ControllerManager.GroupClient + local data = {} - local _client = ControllerManager.GroupClient - local data = {} - - data.id = group_id - data.uid = uid + data.id = group_id + data.uid = uid data.parent_id = parent_id - data.limit = limit - data.num = num + data.limit = limit + data.num = num - data.tt = time_type + data.tt = time_type if time_type == 0 then data.bt = begin_time data.et = end_time end - + _client:send(Protocol.WEB_FG_GET_PARTNER_STAT_PLAY, data, function(res) callback(res) end) end - -- 获取合伙人成员列表 function M:FG_GetPartnerMembers(group_id, partner_id, limit, num, quary_id, callback) local _client = ControllerManager.GroupClient @@ -666,13 +649,13 @@ end -- 获取管理员/合伙人上下分 function M:FG_GetMngHpLog(group_id, limit, num, hp_type, qid, qName, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num - data.type = hp_type - data.qid = qid - data.tagName = qName + local data = {} + data.id = group_id + data.limit = limit + data.num = num + data.type = hp_type + data.qid = qid + data.tagName = qName _client:send(Protocol.WEB_FG_GET_MNG_HP_LOG, data, function(res) callback(res) end) @@ -681,21 +664,21 @@ end -- 获取管理员上下分统计 function M:FG_GetMngHpStatistic(group_id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id + local data = {} + data.id = group_id _client:send(Protocol.WEB_FG_MNG_HP_STATISTIC, data, function(res) callback(res) end) end -- 获取管理员上下分详情 -function M:FG_GetMngHpInfo(group_id, type, begin_time, end_time, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.type = type +function M:FG_GetMngHpInfo(group_id, type, begin_time, end_time, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.type = type data.beginTime = begin_time - data.endTime = end_time + data.endTime = end_time _client:send(Protocol.WEB_FG_MNG_HP_INFO, data, function(res) callback(res) end) @@ -715,9 +698,9 @@ end -- 获取玩家体力值日统计 function M:FG_GetPlayerDailyHPCount(group_id, id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = id + local data = {} + data.id = group_id + data.tagId = id _client:send(Protocol.WEB_FG_GET_PLAYER_DAILY_COUNT, data, function(res) callback(res) end) @@ -726,111 +709,108 @@ end -- 获取体力值日志牌局明细 function M:FG_GetHpLogDetail(group_id, id, roomid, time, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = id - data.roomId = roomid - data.time = time + local data = {} + data.id = group_id + data.tagId = id + data.roomId = roomid + data.time = time _client:send(Protocol.WEB_FG_HPLOG_DETAIL_INFO, data, function(res) callback(res) end) end --获取所有玩法 -function M:FG_GetAllplays(groupid,uid,callback) +function M:FG_GetAllplays(groupid, uid, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = groupid - data.uid = uid + local data = {} + data.id = groupid + data.uid = uid _client:send(Protocol.WEB_FG_GET_ALLPLAYS, data, function(res) callback(res) end) end --设置屏蔽玩法 -function M:FG_SetBanPlayid(groupId,pid,ban,uid,callback) +function M:FG_SetBanPlayid(groupId, pid, ban, uid, callback) local _client = ControllerManager.GroupClient - local data = {} - data.groupid = groupId - data.pid = pid - data.ban = ban - data.uid = uid + local data = {} + data.groupid = groupId + data.pid = pid + data.ban = ban + data.uid = uid _client:send(Protocol.WEB_FG_SET_BANPLAYID, data, function(res) callback(res) end) end -- 获取推广奖励值 -function M:FG_GetRewards(group_id, pid, lev, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = pid +function M:FG_GetRewards(group_id, pid, lev, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.tagId = pid data.partnerLev = lev _client:send(Protocol.WEB_FG_GET_REWARDS, data, function(res) callback(res) end) end - - -- 设置推广奖励值 -function M:FG_SetRewards(group_id, tag, lev, partner_id, all, val, single,callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.pid = tag +function M:FG_SetRewards(group_id, tag, lev, partner_id, all, val, single, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.pid = tag data.partnerLev = lev - data.value = val - data.tagId = partner_id - data.all = all - data.single = single + data.value = val + data.tagId = partner_id + data.all = all + data.single = single _client:send(Protocol.WEB_FG_SET_REWARDS, data, function(res) callback(res) end) end -function M:FG_SetXIPAI(group_id, tag, lev, partner_id, all, val, single,callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.pid = tag +function M:FG_SetXIPAI(group_id, tag, lev, partner_id, all, val, single, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.pid = tag data.partnerLev = lev - data.value = val - data.tagId = partner_id - data.all = all - data.single = single + data.value = val + data.tagId = partner_id + data.all = all + data.single = single _client:send(Protocol.WEB_FG_SET_XIPAI, data, function(res) callback(res) end) end -function M:FG_SetANCHOU(group_id, tag, lev, partner_id, all, val, single,callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.pid = tag +function M:FG_SetANCHOU(group_id, tag, lev, partner_id, all, val, single, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.pid = tag data.partnerLev = lev - data.value = val - data.tagId = partner_id - data.all = all - data.single = single + data.value = val + data.tagId = partner_id + data.all = all + data.single = single _client:send(Protocol.WEB_FG_SET_ANCHOU, data, function(res) callback(res) end) end - -- 获取奖励日志 function M:FG_GetRewardsLog(group_id, limit, num, begin_time, end_time, tag, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = tag - data.limit = limit - data.num = num + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.tagId = tag + data.limit = limit + data.num = num data.beginTime = begin_time - data.endTime = end_time + data.endTime = end_time _client:send(Protocol.WEB_FG_GET_REWARDS_LOG, data, function(res) callback(res) end) @@ -838,55 +818,55 @@ end -- 获取奖励统计 function M:FG_GetRewardStatistic(group_id, pid, begin_time, end_time, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.pid = pid + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.pid = pid data.beginTime = begin_time - data.endTime = end_time + data.endTime = end_time _client:send(Protocol.WEB_FG_GET_REWARDS_STATISTIC, data, function(res) callback(res) end) end -- 排行 -function M:FG_GetMemberRank(group_id, pid, limit, num, begin_time, end_time, type,callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.pid = pid +function M:FG_GetMemberRank(group_id, pid, limit, num, begin_time, end_time, type, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.pid = pid data.beginTime = begin_time - data.endTime = end_time - data.limit = limit - data.num = num - data.type = type + data.endTime = end_time + data.limit = limit + data.num = num + data.type = type _client:send(Protocol.WEB_FG_MEMBER_RANK, data, function(res) callback(res) end) end -- 局数统计 -function M:FG_GetRoundStat(group_id, pid, callback) +function M:FG_GetRoundStat(group_id, pid, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.pid = pid + local data = {} + data.id = group_id + data.pid = pid _client:send(Protocol.WEB_FG_GET_ROUND_STATISTIC, data, function(res) callback(res) end) end -- 获取成员体力值日志 -function M:FG_GetMemberHpLog(group_id, tag, limit, num, filter, begin_time, end_time, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = tag - data.limit = limit - data.num = num - data.choose = filter +function M:FG_GetMemberHpLog(group_id, tag, limit, num, filter, begin_time, end_time, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.tagId = tag + data.limit = limit + data.num = num + data.choose = filter data.beginTime = begin_time - data.endTime = end_time + data.endTime = end_time _client:send(Protocol.WEB_FG_GET_MEMBER_HP_LOG, data, function(res) callback(res) end) @@ -895,20 +875,20 @@ end -- 获取玩法局数统计 function M:FG_GetGameStat(group_id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id + local data = {} + data.id = group_id _client:send(Protocol.WEB_FG_GET_GAME_ROUND_STATISTIC, data, function(res) callback(res) end) end -- 获取消费统计 -function M:FG_GetConsumeStat(group_id,begin_time, end_time, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id +function M:FG_GetConsumeStat(group_id, begin_time, end_time, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id data.beginTime = begin_time - data.endTime = end_time + data.endTime = end_time _client:send(Protocol.WEB_FG_GET_CONSUME_STATISTIC, data, function(res) callback(res) end) @@ -916,13 +896,13 @@ end -- 获取赢家抽水记录 function M:FG_GetPropLog(group_id, limit, num, begin_time, end_time, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.limit = limit + data.num = num data.beginTime = begin_time - data.endTime = end_time + data.endTime = end_time _client:send(Protocol.WEB_FG_GET_PROPORTION_LOG, data, function(res) callback(res) end) @@ -931,30 +911,31 @@ end -- 获取战绩 function M:FG_GetGroupRecord(group_id, platform, qid, limit, num, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.qid = qid + local data = {} + data.id = group_id + data.qid = qid data.platform = platform - data.limit = limit - data.num = num + data.limit = limit + data.num = num _client:send(Protocol.WEB_FG_GET_RECORD, data, function(res) callback(res) end) end -- 获取战绩 -function M:FG_GetGroupRecordSpe(group_id, platform, qid, includeMembers, limit, num, begin_time, end_time, time_type, callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.qid = qid - data.platform = platform +function M:FG_GetGroupRecordSpe(group_id, platform, qid, includeMembers, limit, num, begin_time, end_time, time_type, + callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.qid = qid + data.platform = platform data.includeMembers = includeMembers - data.limit = limit - data.num = num - data.bt = begin_time - data.et = end_time - data.tt = time_type + data.limit = limit + data.num = num + data.bt = begin_time + data.et = end_time + data.tt = time_type _client:send(Protocol.WEB_FG_GET_RECORD, data, function(res) callback(res) end) @@ -963,10 +944,10 @@ end -- 获取战绩 function M:FG_GetGroupPersonRecord(group_id, platform, qid, time_type, begin_time, end_time, limit, num, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.qid = qid - data.tt = time_type + local data = {} + data.id = group_id + data.qid = qid + data.tt = time_type if time_type == 3 then data.bt = begin_time data.et = end_time @@ -979,13 +960,12 @@ function M:FG_GetGroupPersonRecord(group_id, platform, qid, time_type, begin_tim end) end - -- 根据房间号查询战绩 -function M:FG_GetRecordByRoomid(group_id, roomid, platform, callback) +function M:FG_GetRecordByRoomid(group_id, roomid, platform, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.roomid = roomid + local data = {} + data.id = group_id + data.roomid = roomid data.platform = platform _client:send(Protocol.WEB_FG_GET_RECORD_BY_ROOMID, data, function(res) callback(res) @@ -993,117 +973,107 @@ function M:FG_GetRecordByRoomid(group_id, roomid, platform, callback) end -- 获取能量包数据 -function M:FG_GetTakeInfo(group_id, tagId,callback) +function M:FG_GetTakeInfo(group_id, tagId, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = tagId + local data = {} + data.id = group_id + data.tagId = tagId _client:send(Protocol.WEB_FG_GET_TAKE_INFO, data, function(res) callback(res) end) end - -- 获取银行信息 -function M:FG_GetBankInfo(group_id, tagId,callback) +function M:FG_GetBankInfo(group_id, tagId, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.tagId = tagId + local data = {} + data.id = group_id + data.tagId = tagId _client:send(Protocol.GET_BANK_HP, data, function(res) callback(res) end) end - - -function M:FG_TakeBankInfo(group_id, gethp,tagId,callback) +function M:FG_TakeBankInfo(group_id, gethp, tagId, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.hp=gethp - data.tagId = tagId + local data = {} + data.id = group_id + data.hp = gethp + data.tagId = tagId _client:send(Protocol.TAKE_BANK_HP, data, function(res) callback(res) end) end - -function M:FG_SAVEBankInfo(group_id, gethp,tagId,callback) +function M:FG_SAVEBankInfo(group_id, gethp, tagId, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.hp=gethp - data.tagId = tagId + local data = {} + data.id = group_id + data.hp = gethp + data.tagId = tagId _client:send(Protocol.SAVE_BANK_HP, data, function(res) callback(res) end) end - - - - -- 提取体力值 -function M:FG_TakeHp(group_id, num, tagId,callback) +function M:FG_TakeHp(group_id, num, tagId, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.hp = num - data.tagId = tagId + local data = {} + data.id = group_id + data.hp = num + data.tagId = tagId _client:send(Protocol.WEB_FG_TAKE_FAG, data, function(res) callback(res) end) end -- 获取提取记录 -function M:FG_GetTakeLog(group_id, limit, num, begin_time, end_time, tagId,callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num +function M:FG_GetTakeLog(group_id, limit, num, begin_time, end_time, tagId, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.limit = limit + data.num = num data.beginTime = begin_time - data.endTime = end_time - data.tagId = tagId + data.endTime = end_time + data.tagId = tagId _client:send(Protocol.WEB_FG_FAG_TAKE_LOG, data, function(res) callback(res) end) end - -- 获取提取记录 -function M:FG_GetBankLog(group_id, limit, num, begin_time, end_time, tagId,callback) - local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id - data.limit = limit - data.num = num +function M:FG_GetBankLog(group_id, limit, num, begin_time, end_time, tagId, callback) + local _client = ControllerManager.GroupClient + local data = {} + data.id = group_id + data.limit = limit + data.num = num data.beginTime = begin_time - data.endTime = end_time - data.tagId = tagId + data.endTime = end_time + data.tagId = tagId _client:send(Protocol.WEB_FG_GET_BANK_LOG, data, function(res) callback(res) end) end - -- 获取能量包统计 function M:FG_GetFagPackInfo(group_id, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = group_id + local data = {} + data.id = group_id _client:send(Protocol.WEB_FG_FAG_PACK_INFO, data, function(res) callback(res) end) end --圈删除玩家 -function M:FG_GroupRemoveMember(id,tagId,callback) +function M:FG_GroupRemoveMember(id, tagId, callback) local _client = ControllerManager.GroupClient - local data = {} - data.id = id - data.tagId = tagId + local data = {} + data.id = id + data.tagId = tagId _client:send(Protocol.WEB_FG_GROUP_KICK, data, function(res) if res.ReturnCode == 0 then local group = DataManager.groups:get(id) @@ -1112,6 +1082,7 @@ function M:FG_GroupRemoveMember(id,tagId,callback) callback(res) end) end + function M:FG_GroupSetVip(group_id, member_id, isvip, callback) local _client = ControllerManager.GroupClient local _data = {} @@ -1119,7 +1090,7 @@ function M:FG_GroupSetVip(group_id, member_id, isvip, callback) _data.tagId = member_id _data.isvip = isvip _client:send(Protocol.WEB_FG_SET_GROUP_VIP, _data, function(res) - if res.ReturnCode == 0 then + if res.ReturnCode == 0 then local group = DataManager.groups:get(group_id) local member = group:getMember(member_id) if member then @@ -1129,21 +1100,22 @@ function M:FG_GroupSetVip(group_id, member_id, isvip, callback) callback(res) end) end -function M:FG_EnterGroup(group_id,callback) + +function M:FG_EnterGroup(group_id, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id - printlog("FG_EnterGroup===>>>",_data.id) + printlog("FG_EnterGroup===>>>", _data.id) _client:send(Protocol.WEB_ENTER_GROUP, _data, function(res) if res.ReturnCode == 0 then -- 获取玩法列表 local group = DataManager.groups:get(group_id) group:clear() - group.notice = res.Data.notice - group.hide_action = res.Data.hide_action - + group.notice = res.Data.notice + group.hide_action = res.Data.hide_action + self.mgr_ctr = ControllerManager.GetController(GroupMgrController) - self.mgr_ctr:connect(res.Data.host,group_id,function(res1) + self.mgr_ctr:connect(res.Data.host, group_id, function(res1) if res1.ReturnCode == 0 then callback(res) else @@ -1153,7 +1125,6 @@ function M:FG_EnterGroup(group_id,callback) else callback(res) end - end) end @@ -1164,7 +1135,7 @@ function M:FG_ExitGroupMgr() end --指定圈删除房间 -function M:FG_RemoveRoom(group_id,roomid,callback) +function M:FG_RemoveRoom(group_id, roomid, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id @@ -1200,7 +1171,7 @@ function M:FG_SetManager(group_id, member_id, opt, callback) end) end --- 设置成员禁止娱乐 +-- 设置成员禁止娱乐 function M:FG_BanMember(group_id, member_id, ban, opType, callback) local _client = ControllerManager.GroupClient local _data = {} @@ -1209,7 +1180,7 @@ function M:FG_BanMember(group_id, member_id, ban, opType, callback) _data.ban = ban _data.opType = opType _client:send(Protocol.WEB_FG_BAN_MEMBER, _data, function(res) - if res.ReturnCode == 0 then + if res.ReturnCode == 0 then local group = DataManager.groups:get(group_id) local member = group:getMember(member_id) if member then @@ -1221,45 +1192,40 @@ function M:FG_BanMember(group_id, member_id, ban, opType, callback) end) end - --- 获取成员调度 -function M:FG_GetBanMemberHB(group_id, member_id,callback) +-- 获取成员调度 +function M:FG_GetBanMemberHB(group_id, member_id, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id _data.tagId = member_id _client:send(Protocol.GROUP_GET_BLACK_MEMBER, _data, function(res) callback(res) - end) end - --- 设置成员调度 -function M:FG_BanMemberHB(group_id, member_id,opt,ban_rate,black_max_value,callback) +-- 设置成员调度 +function M:FG_BanMemberHB(group_id, member_id, opt, ban_rate, black_max_value, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id _data.tagId = member_id - _data.ban =opt + _data.ban = opt _data.opType = 2 _data.ban_rate = ban_rate _data.ban_max_value = black_max_value - + _client:send(Protocol.GROUP_BLACK_MEMBER, _data, function(res) - if res.ReturnCode == 0 then + if res.ReturnCode == 0 then local group = DataManager.groups:get(group_id) local member = group:getMember(member_id) if member then - member.group_black=opt + member.group_black = opt end end callback(res) - end) end - -- 设置禁止同桌 function M:FG_SetBanTable(group_id, member_id, list, del_list, callback) if #list == 0 then table.insert(list, 0) end @@ -1285,8 +1251,7 @@ function M:FG_GetBanTable(group_id, member_id, callback) end) end - -function M:GetAddMember(group_id,member_id,callback) +function M:GetAddMember(group_id, member_id, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id @@ -1296,9 +1261,8 @@ function M:GetAddMember(group_id,member_id,callback) end) end - --添加成员 -function M:FG_AddMember(group_id,member_id,callback) +function M:FG_AddMember(group_id, member_id, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id @@ -1309,7 +1273,7 @@ function M:FG_AddMember(group_id,member_id,callback) end -- 改变体力值 -function M:FG_ChangeFag(group_id,member_id,fag,callback ) +function M:FG_ChangeFag(group_id, member_id, fag, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id @@ -1321,7 +1285,7 @@ function M:FG_ChangeFag(group_id,member_id,fag,callback ) end -- 获取合伙人列表 -function M:FG_PartnerList(group_id, index, num, qid, callback) +function M:FG_PartnerList(group_id, index, num, qid, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id @@ -1365,7 +1329,7 @@ function M:FG_SetMngPermission(group_id, target, permission, callback) local group = DataManager.groups:get(group_id) local member = group:getMember(target) if member then - member.permission = permission + member.permission = permission end end callback(res) @@ -1421,7 +1385,7 @@ function M:FG_SetPartnerThreshold(group_id, uid, score, callback) end) end -function M:FG_StopService(group_id,ban,callback) +function M:FG_StopService(group_id, ban, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id @@ -1447,7 +1411,7 @@ function M:FG_AddPlay(group_id, game_id, config_data, name, hpData, hpOnOff, gty end) end -function M:FG_DelPlay(group_id,pid,callback) +function M:FG_DelPlay(group_id, pid, callback) local _client = ControllerManager.GroupClient local _data = {} _data.id = group_id @@ -1494,4 +1458,4 @@ function M:FG_UpdatePlay(group_id, game_id, config_data, name, hpData, hpOnOff, _client:send(Protocol.WEB_FG_UPDATE_PLAY, _data, function(res) callback(res) end) -end \ No newline at end of file +end diff --git a/lua_probject/base_project/Game/Controller/RoomController.lua b/lua_probject/base_project/Game/Controller/RoomController.lua index 0d2f6a88..148e7cb1 100644 --- a/lua_probject/base_project/Game/Controller/RoomController.lua +++ b/lua_probject/base_project/Game/Controller/RoomController.lua @@ -102,7 +102,7 @@ function M:CreateRoom(game_id, _data, callback) local extend = ExtendManager.GetExtendConfig(room.game_id) extend:FillRoomData(_s2croom) ControllerManager.ChangeController(GameController) - -- print("create room:"..(os.clock()-runtime)) + -- -- print("create room:"..(os.clock()-runtime)) callback(response) return end diff --git a/lua_probject/base_project/Game/ControllerManager.lua b/lua_probject/base_project/Game/ControllerManager.lua index 69702a65..394d1bd3 100644 --- a/lua_probject/base_project/Game/ControllerManager.lua +++ b/lua_probject/base_project/Game/ControllerManager.lua @@ -31,7 +31,7 @@ function ControllerManager.Init() local hostIp = GetGameInfo("login_url") if (debug_print) then - print("hostIp:::" .. hostIp) + -- print("hostIp:::" .. hostIp) end ControllerManager.WebClient = NetClient.new(hostIp, "majiang", ConnectionProtocol.Web) --ControllerManager.GroupClient = nil--NetClient.new("http://192.168.0.1:8081/", "web_group", ConnectionProtocol.Web) @@ -76,7 +76,7 @@ function ControllerManager.SetGameNetClient(client) end function ControllerManager.OnConnect(code) - print("=======================================ControllerManager", code) + -- print("=======================================ControllerManager", code) if (code ~= SocketCode.Connect) then ControllerManager.SetGameNetClient(nil) if code ~= SocketCode.DisconnectByServer then diff --git a/lua_probject/base_project/Game/Data/TableBG.lua b/lua_probject/base_project/Game/Data/TableBG.lua index 60add02b..981b630e 100644 --- a/lua_probject/base_project/Game/Data/TableBG.lua +++ b/lua_probject/base_project/Game/Data/TableBG.lua @@ -5,12 +5,12 @@ local TableBG = {} local M = TableBG local bg_config = { - {id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04"}, - {id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05"}, - {id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06"}, - {id = 4, url = "base/tablebg/bg/bg7", thumb = "ui://Common/b01"}, - {id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02"}, - {id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03"}, + { id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04" }, + { id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05" }, + { id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06" }, + { id = 4, url = "base/tablebg/bg/bg7", thumb = "ui://Common/b01" }, + { id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02" }, + { id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03" }, } function TableBG.GetBGConfig(config) @@ -41,7 +41,7 @@ local function SetBG(data, game_id, bg_id) if not contain_key then local _data = {} _data.game_id = game_id - _data.bg_id = bg_id + _data.bg_id = bg_id table.insert(data, _data) end end @@ -49,12 +49,12 @@ end function TableBG.GetTableBG(game_id) local id = -1 local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code) - -- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id) - if json_data ~= nil then - local config_data = json.decode(json_data) - id = GetBG(config_data, game_id) - end - return id + -- -- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id) + if json_data ~= nil then + local config_data = json.decode(json_data) + id = GetBG(config_data, game_id) + end + return id end function TableBG.LoadTableBG(id, game_id, main_view, config) @@ -80,13 +80,13 @@ end function TableBG.SaveTableBG(game_id, bg_id) local config_data local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code) - if json_data ~= nil then - config_data = json.decode(json_data) - else - config_data = {} - end + if json_data ~= nil then + config_data = json.decode(json_data) + else + config_data = {} + end SetBG(config_data, game_id, bg_id) Utils.SaveLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code, json.encode(config_data)) end -return M \ No newline at end of file +return M diff --git a/lua_probject/base_project/Game/ExtendHotupdate.lua b/lua_probject/base_project/Game/ExtendHotupdate.lua index 523e872a..7f8b7834 100644 --- a/lua_probject/base_project/Game/ExtendHotupdate.lua +++ b/lua_probject/base_project/Game/ExtendHotupdate.lua @@ -18,7 +18,7 @@ local function __ShowTip(_version_view, text, callback) end local function __update_check(data, onback, _version_view) - print("===================updateCheck") + -- print("===================updateCheck") local tex_tip = _version_view:GetChild("tex_info") for k, game_data in ipairs(data) do local asset_path = game_data["bundle"]:gsub("\r\n", "") diff --git a/lua_probject/base_project/Game/ExtendManager.lua b/lua_probject/base_project/Game/ExtendManager.lua index d1762db1..5e8acc3e 100644 --- a/lua_probject/base_project/Game/ExtendManager.lua +++ b/lua_probject/base_project/Game/ExtendManager.lua @@ -13,7 +13,7 @@ local _isInit = false local function __new_config(data) local ec = reimport(data.bundle .. ".ExtendConfig") - print("初始化ExtendManager===>>>" .. data.bundle) + -- print("初始化ExtendManager===>>>" .. data.bundle) --pt(data) local config = ec.new() ec.game_data = data diff --git a/lua_probject/base_project/Game/View/Common/BaseWindow.lua b/lua_probject/base_project/Game/View/Common/BaseWindow.lua index 92f8d336..d8a6db50 100644 --- a/lua_probject/base_project/Game/View/Common/BaseWindow.lua +++ b/lua_probject/base_project/Game/View/Common/BaseWindow.lua @@ -2,46 +2,46 @@ --author:-- BaseWindow = { - --view description - _view = nil, + --view description + _view = nil, - --View 是否被销毁 - _is_destroy = false, - --是否播放动画 - _animation = true, - --弹出动画,0关闭,1左边,2右边 - _anim_pop = 0, - --关闭摧毁 - _close_destroy = false, + --View 是否被销毁 + _is_destroy = false, + --是否播放动画 + _animation = true, + --弹出动画,0关闭,1左边,2右边 + _anim_pop = 0, + --关闭摧毁 + _close_destroy = false, - --点击窗口以外关闭 - _close_zone = true, + --点击窗口以外关闭 + _close_zone = true, - --队列 - _queue = true, - --全屏 - _full = false, - --全屏偏移 - _full_offset = true, - --新窗口隐藏队列 - _new_hide = true, - --模糊组件对象 - _put_map = true + --队列 + _queue = true, + --全屏 + _full = false, + --全屏偏移 + _full_offset = true, + --新窗口隐藏队列 + _new_hide = true, + --模糊组件对象 + _put_map = true } --window 列表 local WindowMap = { - + } -local WindowQueue= { - +local WindowQueue = { + } local M = BaseWindow -function BaseWindow.new(url,blur_view) - local self = setmetatable({}, {__index = M}) +function BaseWindow.new(url, blur_view) + local self = setmetatable({}, { __index = M }) self.class = "BaseWindow" -- self._blur_view = blur_view self:init(url) @@ -68,13 +68,13 @@ function M:init(url) printlog(self._view) -- self._view.fairyBatching = true local btn_close = self._view:GetChild("btn_close") - if(btn_close) then + if (btn_close) then btn_close.onClick:Set(function() - self:CloseEvent() - end) + self:CloseEvent() + end) end - + local win_mode = self._root_view:GetChild("win_mode") win_mode.onClick:Set(function() if not self._close_zone then @@ -83,29 +83,29 @@ function M:init(url) win_mode.touchable = false self:CloseEvent() end) - printlog("======================================",self._full) + printlog("======================================", self._full) if self._full then local offset = get_offset(self._full_offset) if self._anim_pop == 0 then self._view:AddRelation(contentPane, RelationType.Size) - contentPane:AddChild(self._view) - else - contentPane:RemoveRelation(self._root_view, RelationType.Center_Center) - contentPane:AddRelation(self._root_view, RelationType.Middle_Middle) + contentPane:AddChild(self._view) + else + contentPane:RemoveRelation(self._root_view, RelationType.Center_Center) + contentPane:AddRelation(self._root_view, RelationType.Middle_Middle) PopPanel:AddChild(self._view) local click_item = PopPanel:GetChild("click_item") - if self._anim_pop == 1 then - contentPane:AddRelation(self._root_view, RelationType.Left_Left) - self._view.x = 0 - elseif self._anim_pop == 2 then - contentPane:AddRelation(self._root_view, RelationType.Right_Right) - self._view.x = GRoot.inst.width - self._view.width - offset - end - self._view.y = (PopPanel.height - self._view.height) * 0.5 + if self._anim_pop == 1 then + contentPane:AddRelation(self._root_view, RelationType.Left_Left) + self._view.x = 0 + elseif self._anim_pop == 2 then + contentPane:AddRelation(self._root_view, RelationType.Right_Right) + self._view.x = GRoot.inst.width - self._view.width - offset + end + self._view.y = (PopPanel.height - self._view.height) * 0.5 click_item.xy = self._view.xy click_item.width = self._view.width click_item.height = self._view.height - end + end else contentPane:AddChild(self._view) contentPane.height = self._view.height @@ -114,13 +114,13 @@ function M:init(url) end self._contentPane = contentPane if self._put_map then - WindowMap[#WindowMap + 1] = self + WindowMap[#WindowMap + 1] = self end end -- 显示窗口 function M:Show() - print("===========================================entershow",M.class) + -- print("===========================================entershow",M.class) local contentPane = self._root_view:GetChild("contentPane") if self._anim_pop == 1 then contentPane:GetTransition("left_pop"):Play() @@ -140,7 +140,7 @@ function M:Show() local _inQueue = false if self._new_hide then - for i=1,#WindowQueue do + for i = 1, #WindowQueue do local win = WindowQueue[i] if win == self then _inQueue = true @@ -159,7 +159,7 @@ function M:Show() self._contentPane.width = GRoot.inst.width - 2 * offset self._contentPane.height = GRoot.inst.height self._contentPane.x = offset - end + end end -- 关闭窗口 @@ -168,9 +168,9 @@ function M:Close() -- BlurView(self._blur_view,false) -- end if self._queue then - for i,v in ipairs(WindowQueue) do + for i, v in ipairs(WindowQueue) do if v == self then - table.remove(WindowQueue,i) + table.remove(WindowQueue, i) break end end @@ -194,9 +194,9 @@ function M:Destroy() if not _destroy_all then self:Close() if self._put_map then - for i,v in ipairs(WindowMap) do + for i, v in ipairs(WindowMap) do if v == self then - table.remove(WindowMap,i) + table.remove(WindowMap, i) break end end @@ -212,16 +212,16 @@ function M:CloseEvent() if self._close_destroy then self:Destroy() else - self:Close() - win_mode.touchable = true + self:Close() + win_mode.touchable = true end else self:ActionWithAnim(function() if self._close_destroy then self:Destroy() else - self:Close() - win_mode.touchable = true + self:Close() + win_mode.touchable = true end end) end @@ -245,11 +245,11 @@ end function BaseWindow.DestroyAll() _destroy_all = true local list = WindowMap - for i=1,#list do + for i = 1, #list do local win = list[i] win:Destroy() end _destroy_all = false WindowQueue = {} WindowMap = {} -end \ No newline at end of file +end diff --git a/lua_probject/base_project/Game/View/Family/CreatePlayView.lua b/lua_probject/base_project/Game/View/Family/CreatePlayView.lua index 52aa2a18..f44113b0 100644 --- a/lua_probject/base_project/Game/View/Family/CreatePlayView.lua +++ b/lua_probject/base_project/Game/View/Family/CreatePlayView.lua @@ -52,13 +52,13 @@ function M:init(url) list_playName.onClickItem:Add(function() self.showView.visible = false local index = PlayInfo[1].playList[self.playNameCtr.selectedIndex + 1].playeId - local playDetail = view:GetChild(string.format("Label_Detail_%d",index)) + local playDetail = view:GetChild(string.format("Label_Detail_%d", index)) local playView if not playDetail then - playDetail = UIPackage.CreateObjectFromURL(string.format("ui//Family/Label_Detail_%d",index)) + playDetail = UIPackage.CreateObjectFromURL(string.format("ui//Family/Label_Detail_%d", index)) if playDetail then playView = view:AddChild(playDetail) - playView.name = string.format("Label_Detail_%d",index) + playView.name = string.format("Label_Detail_%d", index) end end if not playDetail then @@ -74,23 +74,23 @@ function M:init(url) self.showView = view:GetChild(string.format("Label_Detail_%d", PlayInfo[1].playList[self.playNameCtr.selectedIndex + 1].playeId)) -----------创建玩法---------- - view:GetChild('btn_Create').onClick:Add(function() - self:CreatePlay() - end) + view:GetChild('btn_Create').onClick:Add(function() + self:CreatePlay() + end) end function M:CreatePlay() - ViewUtil.ShowModalWait(self._root_view,"正在创建房间...") + ViewUtil.ShowModalWait(self._root_view, "正在创建房间...") local loddyCtr = ControllerManager.GetController(LoddyController) - local gameId = PlayInfo[1].playList[self.playNameCtr.selectedIndex+1].playeId + local gameId = PlayInfo[1].playList[self.playNameCtr.selectedIndex + 1].playeId local config = ExtendManager.GetExtendConfig(gameId) - print("==============================config") + -- print("==============================config") pt(config) local mode = config:GetGameInfo() - print("==============================mode") + -- print("==============================mode") pt(mode) local _data = mode:SelectedConfigData() - print("==============================_data") + -- print("==============================_data") pt(_data) -- loddyCtr:CreateRoom(gameId,_data, function (res) -- self:__OnCreateRoomAction(res) @@ -111,7 +111,7 @@ function M:initePlayInfo() local games = DataManager.SelfUser.games for i = 1, #games do if PlayInfo[1].playListInfo[games[i].game_id] then - table.insert(PlayInfo[1].playList,PlayInfo[1].playListInfo[games[i].game_id]) + table.insert(PlayInfo[1].playList, PlayInfo[1].playListInfo[games[i].game_id]) end end pt(PlayInfo) diff --git a/lua_probject/base_project/Game/View/FamilyView.lua b/lua_probject/base_project/Game/View/FamilyView.lua index 05a0a6f9..030c9c27 100644 --- a/lua_probject/base_project/Game/View/FamilyView.lua +++ b/lua_probject/base_project/Game/View/FamilyView.lua @@ -258,7 +258,7 @@ function M:ChangeNumber(fgCtr, group_id, limit, num, minus_only, sort_type) list_familyNumber:SetVirtual() fgCtr:FG_GroupMembers(group_id, limit, num, minus_only, sort_type, function(res) local members = res.Data.members - print("==========================res.Data.members") + -- print("==========================res.Data.members") pt(res.Data.members) ViewUtil:CloseModalWait() if res.ReturnCode ~= 0 then @@ -303,7 +303,7 @@ function M:UpdateFamilyRoom(fgCtr, id) } end local roomList = self._group.rooms - print("=========================playList,rooms") + -- print("=========================playList,rooms") pt(playList) pt(roomList) local roomCtr = ControllerManager.GetController(RoomController) @@ -405,7 +405,7 @@ function M:UpdateFamilyRoom(fgCtr, id) end) end local all_num = #playList + #roomList - print("=================================================list_room", list_room, list_room.numItems, all_num) + -- print("=================================================list_room", list_room, list_room.numItems, all_num) pt(list_room) list_room.numItems = all_num list_gamePlay.numItems = #playList + 1 @@ -418,7 +418,7 @@ function M:ConnetFamily(index, groups, isCreate) local list_family = self._view:GetChild('list_family') list_family:SetVirtual() self._group = DataManager.groups:get(groups[index].id) - print("===================================self._group") + -- print("===================================self._group") pt(self._group) self._roomNum = self._group.room_num @@ -533,7 +533,7 @@ function M:OnUpdate() self._group.update_room = false self._fristRoom = true end - print("====================================UpdateFamilyRoom", fgCtr, self._group.id) + -- print("====================================UpdateFamilyRoom", fgCtr, self._group.id) self:UpdateFamilyRoom(fgCtr, self._group.id) end end diff --git a/lua_probject/base_project/Game/View/Lobby/CreateRoomView.lua b/lua_probject/base_project/Game/View/Lobby/CreateRoomView.lua index 2ad6f8ba..1d600074 100644 --- a/lua_probject/base_project/Game/View/Lobby/CreateRoomView.lua +++ b/lua_probject/base_project/Game/View/Lobby/CreateRoomView.lua @@ -36,7 +36,7 @@ function M:OnCreateRoom(mode_data) local mode = mode_data.data --点击建房按钮后保存当前游戏的config local _data = mode:SelectedConfigData() - --print("OnCreateRoom================") + ---- print("OnCreateRoom================") --pt(_data) if not _data["stamina"] then _data["stamina"] = 0 end local user_id = DataManager.SelfUser.account_id diff --git a/lua_probject/base_project/Game/View/Lobby/JoinRoomView.lua b/lua_probject/base_project/Game/View/Lobby/JoinRoomView.lua index 49053828..79945615 100644 --- a/lua_probject/base_project/Game/View/Lobby/JoinRoomView.lua +++ b/lua_probject/base_project/Game/View/Lobby/JoinRoomView.lua @@ -1,4 +1,3 @@ - --进入房间View对象 @@ -9,8 +8,8 @@ local KEY_DEL = "del" local KEY_CLEAR = "reset" function JoinRoomView.new() - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "JoinRoomView" self._currenIndex = 0 self._close_destroy = true @@ -19,45 +18,45 @@ function JoinRoomView.new() end function M:init(url) - BaseWindow.init(self,url) + BaseWindow.init(self, url) self.tex_num = self._view:GetChild("show_text") self:ClearNumTex() - - for i = 0 , 9 do - local obj = self._view:GetChild("btn_num_"..i) - obj.onClick:Add(handler(self , self.OnNumButtonAction)) + + for i = 0, 9 do + local obj = self._view:GetChild("btn_num_" .. i) + obj.onClick:Add(handler(self, self.OnNumButtonAction)) i = i + 1 end local btn_reset = self._view:GetChild("btn_reset") - btn_reset.onClick:Add(handler(self , self.OnNumButtonAction)) + btn_reset.onClick:Add(handler(self, self.OnNumButtonAction)) local btn_del = self._view:GetChild("btn_del") - btn_del.onClick:Add(handler(self , self.OnNumButtonAction)) + btn_del.onClick:Add(handler(self, self.OnNumButtonAction)) end function M:OnNumButtonAction(context) - local typer = string.sub(context.sender.name ,5) + local typer = string.sub(context.sender.name, 5) printlog("==========================OnNumButtonAction==============================") printlog(typer) if typer == KEY_DEL then - if (self._currenIndex > 0) then + if (self._currenIndex > 0) then self._currenIndex = self._currenIndex - 1 printlog("==================test=================") - print("ok") + -- print("ok") printlog(#self._texnum_str) printlog(self._currenIndex) printlog("==================test=================") - self._texnum_str = string.sub(self._texnum_str,0,self._currenIndex) + self._texnum_str = string.sub(self._texnum_str, 0, self._currenIndex) self.tex_num.text = self._texnum_str end elseif typer == KEY_CLEAR then - self:ClearNumTex() + self:ClearNumTex() else if (self._currenIndex < 6) then self._currenIndex = self._currenIndex + 1 - self._texnum_str = self._texnum_str .. string.sub(typer,-1) + self._texnum_str = self._texnum_str .. string.sub(typer, -1) self.tex_num.text = self._texnum_str - if(self._currenIndex == 6) then + if (self._currenIndex == 6) then self:JoinRoom(self._texnum_str) end end @@ -65,19 +64,19 @@ function M:OnNumButtonAction(context) end function M:JoinRoom(str) - ViewUtil.ShowModalWait(self._root_view,"正在加入房间...") + ViewUtil.ShowModalWait(self._root_view, "正在加入房间...") local boddyCtr = ControllerManager.GetController(LoddyController) - boddyCtr:JoinRoom(str, function (response) + boddyCtr:JoinRoom(str, function(response) ViewUtil.CloseModalWait() if response.ReturnCode == -2 then self:JoinRoom(str) return - elseif response.ReturnCode ~=0 then - ViewUtil.ErrorTip(response.ReturnCode,"进入房间失败") + elseif response.ReturnCode ~= 0 then + ViewUtil.ErrorTip(response.ReturnCode, "进入房间失败") return end self:Destroy() - ViewManager.ChangeView(ViewManager.View_Main,DataManager.CurrenRoom.game_id) + ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) end) end diff --git a/lua_probject/base_project/Game/View/Lobby/LobbyPlayerInfoView.lua b/lua_probject/base_project/Game/View/Lobby/LobbyPlayerInfoView.lua index 4dddcb56..60a17d2d 100644 --- a/lua_probject/base_project/Game/View/Lobby/LobbyPlayerInfoView.lua +++ b/lua_probject/base_project/Game/View/Lobby/LobbyPlayerInfoView.lua @@ -21,9 +21,9 @@ function M:init(url) local view = self._view local user = self.user; - print("================phone=====================") + -- print("================phone=====================") for k, v in pairs(user) do - print(string.format("k:%s|v:%s", k, v)) + -- print(string.format("k:%s|v:%s", k, v)) end --show diff --git a/lua_probject/base_project/Game/View/Lobby/LobbyShopView.lua b/lua_probject/base_project/Game/View/Lobby/LobbyShopView.lua index 8f1c0d4c..2d89d432 100644 --- a/lua_probject/base_project/Game/View/Lobby/LobbyShopView.lua +++ b/lua_probject/base_project/Game/View/Lobby/LobbyShopView.lua @@ -3,25 +3,25 @@ local LobbyShopView = {} local M = LobbyShopView -setmetatable(M, {__index = BaseWindow}) +setmetatable(M, { __index = BaseWindow }) local SHOP_LIST = { { - num=2000, - price=300 + num = 2000, + price = 300 }, { - num=1000, - price=165 + num = 1000, + price = 165 }, { - num=300, - price=50 + num = 300, + price = 50 }, } function LobbyShopView.new(Fct_UpdateDiamo) - local self = setmetatable({}, {__index = M}) + local self = setmetatable({}, { __index = M }) self.class = 'ShopView' self._close_destroy = true self:init('ui://Lobby/Shop') @@ -37,28 +37,25 @@ function M:init(url) for i = 1, #SHOP_LIST do local shopChild = UIPackage.CreateObjectFromURL('ui://Lobby/c_shop_child') - shopChild:GetChild('num').text = string.format("%s 张",SHOP_LIST[i].num) + shopChild:GetChild('num').text = string.format("%s 张", SHOP_LIST[i].num) local shopBuyBtn = shopChild:GetChild('btn_buy') - shopBuyBtn:GetChild('sprite').icon = string.format("ui://Lobby/shop_buy_%s",SHOP_LIST[i].price) + shopBuyBtn:GetChild('sprite').icon = string.format("ui://Lobby/shop_buy_%s", SHOP_LIST[i].price) shopBuyBtn.onClick:Set(function() local index = i; if false then - --发送购买给后端 + --发送购买给后端 else --假数据 - print("===================shop====================") - print(SHOP_LIST[index].num) - print(DataManager.SelfUser.diamo) + -- print("===================shop====================") + -- print(SHOP_LIST[index].num) + -- print(DataManager.SelfUser.diamo) DataManager.SelfUser.diamo = DataManager.SelfUser.diamo + SHOP_LIST[index].num - print(DataManager.SelfUser.diamo) + -- print(DataManager.SelfUser.diamo) self.UpdateDiamo() end - end) shopList:AddChild(shopChild) end end - - return M diff --git a/lua_probject/base_project/Game/View/Lobby/NoticeView.lua b/lua_probject/base_project/Game/View/Lobby/NoticeView.lua index ff7db124..ea67f426 100644 --- a/lua_probject/base_project/Game/View/Lobby/NoticeView.lua +++ b/lua_probject/base_project/Game/View/Lobby/NoticeView.lua @@ -2,8 +2,8 @@ local NoticeView = {} local M = NoticeView function NoticeView.new(blur_view) - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "NoticeView" -- self._blur_view = blur_view self:init("ui://Lobby/pop_notice") @@ -12,7 +12,7 @@ function NoticeView.new(blur_view) end function M:init(url) - BaseWindow.init(self,url) + BaseWindow.init(self, url) self._close_destroy = true self._close_zone = true end @@ -33,17 +33,16 @@ function M:FillData(data) else item:GetChild("icon").url = "" end - - item.onClick:Add(function() + + item.onClick:Add(function() self:ShowIndex(i) end) end list.selectedIndex = 0 self:ShowIndex(1) - end -function M:ShowIndex(index) +function M:ShowIndex(index) local title = self._view:GetChild("tex_title") local pic = self._view:GetChild("img") local content = self._view:GetChild("com_content"):GetChild("tex_content") @@ -53,12 +52,10 @@ function M:ShowIndex(index) title.text = notices[index].title content.text = notices[index].content end - + -- pic.text = "" -- pic.text = "" - -- print(pic.text) - - + -- -- print(pic.text) end function M:Destroy(flag) @@ -66,4 +63,4 @@ function M:Destroy(flag) BaseWindow.Destroy(self, flag) end -return M \ No newline at end of file +return M diff --git a/lua_probject/base_project/Game/View/Lobby/PhonePasswordView.lua b/lua_probject/base_project/Game/View/Lobby/PhonePasswordView.lua index e7298f28..bdc41d99 100644 --- a/lua_probject/base_project/Game/View/Lobby/PhonePasswordView.lua +++ b/lua_probject/base_project/Game/View/Lobby/PhonePasswordView.lua @@ -3,8 +3,8 @@ local PhonePasswordView = {} local M = PhonePasswordView function PhonePasswordView.new(callback) - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "PhonePasswordView" self._callback = callback self._close_destroy = true @@ -14,16 +14,16 @@ function PhonePasswordView.new(callback) end function M:init(url) - BaseWindow.init(self,url) + BaseWindow.init(self, url) self.ctr_update = self._view:GetController("update") if DataManager.SelfUser.password then --self.ctr_update.selectedIndex = 1 - --print("DataManager.SelfUser.account_idDataManager.SelfUser.account_idDataManager.SelfUser.account_id ",DataManager.SelfUser.account_id) + ---- print("DataManager.SelfUser.account_idDataManager.SelfUser.account_idDataManager.SelfUser.account_id ",DataManager.SelfUser.account_id) --self._view:GetChild("tex_phone").text = DataManager.SelfUser.account_id--ViewUtil.phone_hide(DataManager.SelfUser.phone) end self._view:GetChild("tex_phone").text = DataManager.SelfUser.account_id - + local btn_getCode = self._view:GetChild("btn_getCode") btn_getCode.onClick:Set(function() self:GetCode() @@ -41,8 +41,8 @@ function M:GetCode() if not phone then return end - local loddyctr = ControllerManager.GetController(LoddyController) - loddyctr:GetPhoneCode(phone,function( res) + local loddyctr = ControllerManager.GetController(LoddyController) + loddyctr:GetPhoneCode(phone, function(res) if res.ReturnCode == 0 then self._view:GetController("code").selectedIndex = 1 self._left_time = 120 @@ -60,12 +60,12 @@ function M:OnUpdate() _left_time = _left_time - deltaTime _left_time = math.max(0, _left_time) local leftTime = math.floor(_left_time) - self._view:GetChild("tex_time").text = tostring(leftTime).."后重新发送" + self._view:GetChild("tex_time").text = tostring(leftTime) .. "后重新发送" self._left_time = _left_time else - self._view:GetController("code").selectedIndex=0 + self._view:GetController("code").selectedIndex = 0 UpdateBeat:Remove(self.OnUpdate, self) - end + end end function M:Destroy() @@ -75,15 +75,14 @@ end --绑定 function M:Bind() - local tex_passwd = self._view:GetChild("tex_passwd") local password = tex_passwd.text - if string.len(password) <6 then + if string.len(password) < 6 then ViewUtil.ShowTips("请输入5位以上的密码") return end local _data = {} - + -- if self.ctr_update.selectedIndex == 1 then -- local code = self:CheckInputCode() @@ -93,24 +92,23 @@ function M:Bind() -- _data.phone = DataManager.SelfUser.phone -- _data.code = code -- end - ViewUtil.ShowModalWait(self._root_view,"正在提交...") - local loddyctr = ControllerManager.GetController(LoddyController) + ViewUtil.ShowModalWait(self._root_view, "正在提交...") + local loddyctr = ControllerManager.GetController(LoddyController) _data.password = password - _data.type =3 + _data.type = 3 - loddyctr:UpdateUserInfo(_data,function( res) + loddyctr:UpdateUserInfo(_data, function(res) ViewUtil.CloseModalWait() - if (res.ReturnCode ==0) then + if (res.ReturnCode == 0) then DataManager.SelfUser.password = "123" if self._callback then self._callback() end else - ViewUtil.ErrorTip(res.ReturnCode,"提交失败") + ViewUtil.ErrorTip(res.ReturnCode, "提交失败") end self:Close() end) end - function M:CheckInputCode() local code = self._view:GetChild("tex_code").text if not (string.len(code) == 6) then @@ -120,4 +118,4 @@ function M:CheckInputCode() return code end -return M \ No newline at end of file +return M diff --git a/lua_probject/base_project/Game/View/Lobby/RankView.lua b/lua_probject/base_project/Game/View/Lobby/RankView.lua index ff2765f3..8b3d8458 100644 --- a/lua_probject/base_project/Game/View/Lobby/RankView.lua +++ b/lua_probject/base_project/Game/View/Lobby/RankView.lua @@ -6,10 +6,10 @@ RankView = {} local M = RankView -function RankView.new( main_view,video ) +function RankView.new(main_view, video) UIPackage.AddPackage("base/rank/ui/Rank") - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "RankView" self._animation = false self._full = true @@ -24,9 +24,8 @@ function RankView.new( main_view,video ) return self end -function M:init( url ) - - BaseWindow.init(self,url) +function M:init(url) + BaseWindow.init(self, url) self._view:GetController("tab").selectedIndex = self._video and 1 or 0 self._curren_tex = "" @@ -37,30 +36,27 @@ function M:init( url ) for i = 0, 9 do local btn = develop_panel:GetChild("btn_" .. i) btn.onClick:Add(function() - if self._curren_len < 6 then - self._curren_tex = self._curren_tex .. i self._curren_len = self._curren_len + 1 self.tex_roomid.text = self._curren_tex if self._curren_len == 6 then - ViewUtil.ShowModalWait(self._root_view) local loddyCtr1 = ControllerManager.GetController(LoddyController) - loddyCtr1:RequestRecordList(function (result) - ViewUtil.CloseModalWait() - if self._is_destroy then - return - end - if result == Table_Error_code.ERR_TIMEOUT then - self:readData() - return - end - if result == 0 then - self:InitRecord1(loddyCtr1.recordList, true) - end - end, self._curren_tex) + loddyCtr1:RequestRecordList(function(result) + ViewUtil.CloseModalWait() + if self._is_destroy then + return + end + if result == Table_Error_code.ERR_TIMEOUT then + self:readData() + return + end + if result == 0 then + self:InitRecord1(loddyCtr1.recordList, true) + end + end, self._curren_tex) end end end) @@ -79,8 +75,6 @@ function M:init( url ) self._curren_len = 0 self.tex_roomid.text = self._curren_tex end) - - end function M:readData() @@ -90,19 +84,18 @@ function M:readData() record_list_1:RemoveChildrenToPool() local loddyCtr1 = ControllerManager.GetController(LoddyController) - loddyCtr1:RequestRecordList(function (result) - if self._is_destroy then - return - end - if result == Table_Error_code.ERR_TIMEOUT then - self:readData() - return - end - - + loddyCtr1:RequestRecordList(function(result) + if self._is_destroy then + return + end + if result == Table_Error_code.ERR_TIMEOUT then + self:readData() + return + end + + self:InitRecord1(loddyCtr1.recordList) - - end) + end) end function M:Show() @@ -118,21 +111,18 @@ end local load_head_num = 0 function M:InitRecord1(recordList, develop_tool) - - --print("InitRecord1=========") + ---- print("InitRecord1=========") pt(recordList) local main_view = self._view -- 战绩 list local record_list_1, ctr_recored, ctr_no_record if develop_tool then - ctr_recored = main_view:GetController("developer") ctr_recored.selectedIndex = 1 record_list_1 = main_view:GetChild("lst_record") local btn_backto_search = main_view:GetChild("btn_backto_search") btn_backto_search.onClick:Set(function() - ctr_recored.selectedIndex = 0 self._curren_tex = "" @@ -146,12 +136,11 @@ function M:InitRecord1(recordList, develop_tool) end record_list_1:RemoveChildrenToPool() ctr_no_record.selectedIndex = #recordList == 0 and 1 or 0 - for i=1, #recordList do - + for i = 1, #recordList do local record_list_item = recordList[i] - local total_score_list = record_list_item.TotalScoreList + local total_score_list = record_list_item.TotalScoreList local item = record_list_1:AddItemFromPool() - + local player_item_list = item:GetChild("big_round") local more_person = #total_score_list >= 6 if more_person then @@ -165,9 +154,9 @@ function M:InitRecord1(recordList, develop_tool) local game_data = ExtendManager.GetGameData(game_id) local room_type_str = record_list_item.GameInfo.name local room_id_str = record_list_item.RoomId - local time =tonumber(record_list_item.Time) + local time = tonumber(record_list_item.Time) local room_time_str = os.date("%Y-%m-%d %H:%M", time) - local item_score_list = record_list_item.GameTimes + local item_score_list = record_list_item.GameTimes local play_back_id = record_list_item.PlayBackId -- 显示 房间号 房间类型 时间 item:GetChild("RoomType").asTextField.text = room_type_str @@ -184,22 +173,22 @@ function M:InitRecord1(recordList, develop_tool) -- 显示 每个玩家的 名字和 分数 -- player_list 是聊天室数据 local player_list = {} - for j=1,#total_score_list do + for j = 1, #total_score_list do local player_list_item = total_score_list[j] local player_item = player_item_list:AddItemFromPool() player_item:GetChild("n0").text = player_list_item.Name local player_score = player_item:GetChild("n1") local score = player_list_item.Score - if hpOnOff == 1 and hpType > 1 then - score = score / 10 - end + if hpOnOff == 1 and hpType > 1 then + score = score / 10 + end if score < 0 then player_item:GetController("num_color").selectedIndex = 1 else player_item:GetController("num_color").selectedIndex = 0 end - player_score.text = score >= 0 and "+"..score or score + player_score.text = score >= 0 and "+" .. score or score player_list[j] = {} player_list[j].id = player_list_item.Id player_list[j].score = score @@ -207,9 +196,9 @@ function M:InitRecord1(recordList, develop_tool) player_list[j].nick = player_list_item.Name end -- 点击事件 - item.onClick:Add(function () - - self:ShowRecord2(play_back_id, room_type_str, room_id_str, room_time_str,item_score_list, game_id, develop_tool, record_list_item) + item.onClick:Add(function() + self:ShowRecord2(play_back_id, room_type_str, room_id_str, room_time_str, item_score_list, game_id, + develop_tool, record_list_item) end) -- 分享 item:GetChild("btn_screenshot").onClick:Set(function() @@ -234,20 +223,20 @@ function M:InitRecord1(recordList, develop_tool) end item:GetChild("name").text = p.Name local score = p.Score - if hpOnOff == 1 and hpType > 1 then - score = score / 10 - end + if hpOnOff == 1 and hpType > 1 then + score = score / 10 + end item:GetChild("score").text = score if score < 0 then item:GetController("di").selectedIndex = 1 end - if p.Portrait and p.Portrait ~= "" then - ImageLoad.Load(p.Portrait, item:GetChild("n9")._iconObject, 1, function( ... ) - load_head_num = load_head_num - 1 - end) + if p.Portrait and p.Portrait ~= "" then + ImageLoad.Load(p.Portrait, item:GetChild("n9")._iconObject, 1, function(...) + load_head_num = load_head_num - 1 + end) else load_head_num = load_head_num - 1 end end - coroutine.start(function ( ... ) + coroutine.start(function(...) local left_time = 4 while (true) do if load_head_num == 0 or left_time == 0 then @@ -266,7 +255,8 @@ function M:InitRecord1(recordList, develop_tool) end) item:GetChild("btn_link").onClick:Set(function() local group_id = record_list_item.group_id and tonumber(record_list_item.group_id) or 0 - ShareChatRoom(record_list_item.RoomId, tostring(os.time()), #item_score_list, room_type_str, group_id, player_list, self._root_view) + ShareChatRoom(record_list_item.RoomId, tostring(os.time()), #item_score_list, room_type_str, group_id, + player_list, self._root_view) end) end end @@ -280,16 +270,16 @@ function M:ShowRecord2(playback_id, room_type, room_id, room_time, item_score, g record_list_2 = self._view:GetChild("n29") self._view:GetController("Record").selectedIndex = 1 end - + local hpOnOff = record_item.hpOnOff local hpType = record_item.GameInfo.hpType - + record_list_2:RemoveChildrenToPool() - for i=1,#item_score do + for i = 1, #item_score do local item_player_info = item_score[i] local play_back_id = item_player_info.PlayBackId local player_score = item_player_info.PlayerList - + local record_item_2 = record_list_2:AddItemFromPool("ui://Rank/Record_Item_2") local player_item_list = record_item_2:GetChild("List") local more_person = #player_score >= 6 @@ -307,29 +297,27 @@ function M:ShowRecord2(playback_id, room_type, room_id, room_time, item_score, g record_item_2:GetChild("Number").text = tostring(i) player_item_list:RemoveChildrenToPool() - for j=1,#player_score do - + for j = 1, #player_score do local player_item = player_item_list:AddItemFromPool() player_item:GetChild("n0").text = player_score[j].Name local player_score_text = player_item:GetChild("n1") local score = player_score[j].Score - if hpOnOff == 1 and hpType > 1 then - score = score / 10 - end + if hpOnOff == 1 and hpType > 1 then + score = score / 10 + end if score < 0 then player_item:GetController("num_color").selectedIndex = 1 else player_item:GetController("num_color").selectedIndex = 0 end - player_score_text.text = score >= 0 and "+"..score or score - + player_score_text.text = score >= 0 and "+" .. score or score end local btn_play_back = record_item_2:GetChild("btn_play_back") btn_play_back.onClick:Set(function() - --print("点击进入回放=====") + ---- print("点击进入回放=====") if DataManager.SelfUser.playback[playback_id] ~= nil and DataManager.SelfUser.playback[playback_id][i] ~= nil then - --print("1111111111111111") - local room = ExtendManager.GetExtendConfig(game_id):NewRoom() + ---- print("1111111111111111") + local room = ExtendManager.GetExtendConfig(game_id):NewRoom() DataManager.CurrenRoom = room room.game_id = game_id local extend = ExtendManager.GetExtendConfig(game_id) @@ -343,13 +331,13 @@ function M:ShowRecord2(playback_id, room_type, room_id, room_time, item_score, g main._totalRound = #item_score main:FillRoomData(DataManager.SelfUser.playback[playback_id][i]) else - --print("2222222222222") + ---- print("2222222222222") ViewUtil.ShowModalWait(self._view) local _data = {} _data["military_id"] = playback_id _data["round"] = tostring(i) local loddyCtr1 = ControllerManager.GetController(LoddyController) - loddyCtr1:RequestPlayBack(_data,function(code,data) + loddyCtr1:RequestPlayBack(_data, function(code, data) ViewUtil.CloseModalWait() if code == 0 then if DataManager.SelfUser.playback[playback_id] ~= nil then @@ -364,31 +352,30 @@ function M:ShowRecord2(playback_id, room_type, room_id, room_time, item_score, g main._currentId = playback_id main._currentRound = i main._totalRound = #item_score - --print(main) + ---- print(main) main:FillRoomData(data) elseif code == 25 then ViewUtil.ErrorTip(code, "回放未找到!") btn_play_back.grayed = true end end, record_item.GameInfo) - end end) end end function M:GenaratePlayBack(id, game_id, ...) - local tem =nil - local dview_class = nil - if not dview_class then - local exconfig = ExtendManager.GetExtendConfig(game_id) - dview_class = exconfig:GetView(id) - --print(dview_class) - end - if not dview_class then - return - end - local arg = {...} + local tem = nil + local dview_class = nil + if not dview_class then + local exconfig = ExtendManager.GetExtendConfig(game_id) + dview_class = exconfig:GetView(id) + ---- print(dview_class) + end + if not dview_class then + return + end + local arg = { ... } tem = dview_class.new(...) tem.Id = id tem:Show() diff --git a/lua_probject/base_project/Game/View/Lobby/UserEditView.lua b/lua_probject/base_project/Game/View/Lobby/UserEditView.lua index a5936f2c..31a78122 100644 --- a/lua_probject/base_project/Game/View/Lobby/UserEditView.lua +++ b/lua_probject/base_project/Game/View/Lobby/UserEditView.lua @@ -7,8 +7,8 @@ local UserEditView = {} local M = UserEditView function UserEditView.new(callback) - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "UserEditView" self._callback = callback self._close_destroy = true @@ -18,7 +18,7 @@ function UserEditView.new(callback) end function M:init(url) - BaseWindow.init(self,url) + BaseWindow.init(self, url) local btn_head = self._view:GetChild("btn_head") ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject) @@ -32,21 +32,21 @@ function M:init(url) local btn_edit_nick = self._view:GetChild("btn_edit_nick") btn_edit_nick.onClick:Set(function() local edit_nick_view = EditNickView.new(function() - tex_nick.text = DataManager.SelfUser.nick_name - self._callback() + tex_nick.text = DataManager.SelfUser.nick_name + self._callback() end) edit_nick_view:Show() end) local btn_edit_portrait = self._view:GetChild("btn_edit_portrait") btn_edit_portrait.onClick:Set(function() - -- local edit_portrait_view = EditPortraitView.new(function() - -- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject) - -- --print(DataManager.SelfUser.head_url) - -- self._callback() - -- end) - -- edit_portrait_view:Show() + -- local edit_portrait_view = EditPortraitView.new(function() + -- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject) + -- ---- print(DataManager.SelfUser.head_url) + -- self._callback() + -- end) + -- edit_portrait_view:Show() end) end -return M \ No newline at end of file +return M diff --git a/lua_probject/base_project/Game/View/LobbyView.lua b/lua_probject/base_project/Game/View/LobbyView.lua index 5c7fc13c..6bf2cd46 100644 --- a/lua_probject/base_project/Game/View/LobbyView.lua +++ b/lua_probject/base_project/Game/View/LobbyView.lua @@ -23,7 +23,7 @@ LobbyView = {} local M = {} function LobbyView.new() - -- print("new lobbyView!!!!") + -- -- print("new lobbyView!!!!") setmetatable(M, { __index = BaseView }) local self = setmetatable({}, { __index = M }) self.class = "LobbyView" @@ -38,7 +38,7 @@ function LobbyView.new() end function M:InitView(url) - -- print("init lobbyView!!!!") + -- -- print("init lobbyView!!!!") BaseView.InitView(self, url) self._full_offset = false local view = self._view @@ -338,7 +338,7 @@ function M:__show_service() end function M:__GetMessage(data) - -- print("on GetMessage~~~~~~~~~~~~~~~~~~~~~~~~~~~") + -- -- print("on GetMessage~~~~~~~~~~~~~~~~~~~~~~~~~~~") if not data or not data.notice_list then self._mesList = "" else @@ -364,7 +364,7 @@ function M:__PopMsg(index) end function M:__moveMsg(index) - -- print("on moveMsg!!!!!!!!!!!!!!!!!!!!!!!!!") + -- -- print("on moveMsg!!!!!!!!!!!!!!!!!!!!!!!!!") if not self._tex_message then return end index, self._tex_message.text = self:__PopMsg(index) self._tex_message.x = self._message.width @@ -392,8 +392,8 @@ end function M:__ShowShare() local pop_share = self._view:GetChild("pop_share") local shareUrl = GetGameInfo("invite_link") .. "?uid=" .. DataManager.SelfUser.account_id - --print("shareUrl=================") - --print(shareUrl) + ---- print("shareUrl=================") + ---- print(shareUrl) local btn_wx_session = pop_share:GetChild("btn_wx_session") btn_wx_session.onClick:Add(function() shareQRCodePicture(shareUrl, 0) @@ -437,7 +437,7 @@ function M:Destroy() end function M:Show() - --print("on lobbyView show~~~~~~") + ---- print("on lobbyView show~~~~~~") BaseView.Show(self) ViewUtil.PlaySoundBg() UpdateBeat:Add(self.OnUpdate, self) diff --git a/lua_probject/base_project/Game/View/LoginView.lua b/lua_probject/base_project/Game/View/LoginView.lua index 425458d7..3dd63dc5 100644 --- a/lua_probject/base_project/Game/View/LoginView.lua +++ b/lua_probject/base_project/Game/View/LoginView.lua @@ -26,7 +26,7 @@ function M:init() local view = self._view -- view:GetChild("tex_version").text = "Version:" .. GetGameInfoPlatform("version") - -- print(GameApplication.Instance.accountTest and 1 or 0) + -- -- print(GameApplication.Instance.accountTest and 1 or 0) view:GetController("test").selectedIndex = GameApplication.Instance.accountTest and 1 or 0 self.agree = view:GetController("agree"); -- Utils.LoadBg("loginbg", view) @@ -70,7 +70,7 @@ function M:init() Utils.SaveLocalFile(key, json.encode(_data)) end) if not s then - print("Error:" .. e) + -- print("Error:" .. e) end DataManager.SelfUser.acc = utez @@ -218,7 +218,7 @@ end function M:QuickLogin() if (not GameApplication.Instance.accountTest) then local session_id = PlayerPrefs.GetString("session_id") - print("session_id:" .. session_id) + -- print("session_id:" .. session_id) if session_id and string.len(session_id) > 3 then ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...") local loginCtr = ControllerManager.GetController(LoginController) @@ -231,8 +231,8 @@ end function M:LoginCallBack(result, data) self.isWXCallBackMark = true - --print("微信登录返回================================================================") - --print("result===>"..result) + ---- print("微信登录返回================================================================") + ---- print("result===>"..result) --pt(data) if (not result) or result ~= 0 then if result == 10 then diff --git a/lua_probject/base_project/Game/View/MainView.lua b/lua_probject/base_project/Game/View/MainView.lua index 1cbe38c7..79171d09 100644 --- a/lua_probject/base_project/Game/View/MainView.lua +++ b/lua_probject/base_project/Game/View/MainView.lua @@ -57,9 +57,9 @@ function M:SetTuoGuanState() end function M:InitView(url, isHideIpAdds) - --print("url===>>>") - --print(url) - --print(debug.traceback()) + ---- print("url===>>>") + ---- print(url) + ---- print(debug.traceback()) BaseView.InitView(self, url) -- @@ -668,7 +668,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.TupGuanOpen, function(...) - --print("刷新托管数据=====") + ---- print("刷新托管数据=====") local arg = { ... } local p = arg[1] local info = self._player_info[self:GetPos(p.seat)] @@ -802,17 +802,17 @@ function M:OnPlayerReady(...) if p.isSendCardState ~= nil and p.isSendCardState == true then p.isSendCardState = false ControllerManager.IsSendCard = false - --print("进入设置计时器控制==========") + ---- print("进入设置计时器控制==========") coroutine.start(function() - --print("计时器倒计时5s=============") + ---- print("计时器倒计时5s=============") coroutine.wait(5) - --print("当前状态==============") - --print(ControllerManager.IsSendCard) + ---- print("当前状态==============") + ---- print(ControllerManager.IsSendCard) if ControllerManager.IsSendCard == true then - --print("以发送开牌======================") + ---- print("以发送开牌======================") return else - --print("开始断线重连") + ---- print("开始断线重连") --ControllerManager.OnConnect(SocketCode.TimeoutDisconnect) ViewManager.refreshGameView() end @@ -1097,7 +1097,7 @@ end --游戏激活 function M:OnApplicationActive() - --print("游戏激活================") + ---- print("游戏激活================") if os.time() - last_pause_time > 15 then last_pause_time = os.time() ControllerManager.WebClient:clearActionQueue() diff --git a/lua_probject/base_project/Game/View/NewGroup/GroupInfoView.lua b/lua_probject/base_project/Game/View/NewGroup/GroupInfoView.lua index 46176d49..0d2a00c4 100644 --- a/lua_probject/base_project/Game/View/NewGroup/GroupInfoView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/GroupInfoView.lua @@ -17,11 +17,11 @@ GroupNumberInputView_Game = import(".MngView.GroupNumberInputView") local GroupInfoView = {} local M = GroupInfoView -local currentSelectPlay=0 +local currentSelectPlay = 0 function GroupInfoView.new(curGroup, fg_info) - setmetatable(M, {__index = BaseView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseView }) + local self = setmetatable({}, { __index = M }) self.class = 'GroupInfoView' self.curGroup = curGroup curGroup.layer = 0 @@ -30,14 +30,14 @@ function GroupInfoView.new(curGroup, fg_info) self.gameIdList = {} self.playIdList = {} self._full = true - self._get_data = false -- 标记是否已获取到数据 + self._get_data = false -- 标记是否已获取到数据 self._showVipRooms = 0 self.lstgameVisible = false self.isShowRoomItem = (self.curGroup.lev == 1 or self.curGroup.lev == 2) DataManager.SelfUser.cur_group = self - self.FillGameItemList={} + self.FillGameItemList = {} self:InitView('ui://NewGroup/Main_GroupInfo') - + return self end @@ -110,12 +110,12 @@ local function RoomWeight1(room) elseif #room.plist == 0 then weight = weight + 0 elseif room.maxPlayers > #room.plist then - weight = 0.5--weight + (10 - room.maxPlayers + #room.plist) + weight = 0.5 --weight + (10 - room.maxPlayers + #room.plist) elseif room.maxPlayers == #room.plist then weight = weight + 1 end room.weight = weight - -- printlog("aaaaaaaaaaaaaaaaaaaccccccccccccccccccccccc ",weight) + -- printlog("aaaaaaaaaaaaaaaaaaaccccccccccccccccccccccc ",weight) --pt(room) return weight end @@ -123,24 +123,24 @@ end -- 房间排序 local function SortRooms(a, b) - -- printlog("SortRooms====》》》》",currentSelectPlay) - if currentSelectPlay==0 then - local rwa = RoomWeight(a) - local rwb = RoomWeight(b) - if rwa ~= rwb then - return rwa > rwb - else - return a.pid rwb + else + return a.pid < b.pid + end + else + local rwa = RoomWeight1(a) + local rwb = RoomWeight1(b) + if rwa ~= rwb then + return rwa < rwb + else + return a.pid < b.pid + end + end end -- 填充房间对象 @@ -165,31 +165,31 @@ local function __fillRoomItem(self, index, item, room) local room_item = self.roomItems[item] local play = self.curGroup:getPlay(room.pid) if not room_item then - room_item = RoomItem.new(item, room.maxPlayers,self.isShowRoomItem) + room_item = RoomItem.new(item, room.maxPlayers, self.isShowRoomItem) self.roomItems[item] = room_item end - + room_item:SetPlay(play) - -- local str="(人数:".. room.maxPlayers - -- if room.limitInRoom then - -- str=str.." 限制积分:"..room.limitInRoom/1000 ..")" - -- else - -- str=str..")" - -- end - - + -- local str="(人数:".. room.maxPlayers + -- if room.limitInRoom then + -- str=str.." 限制积分:"..room.limitInRoom/1000 ..")" + -- else + -- str=str..")" + -- end + + local str = "" if room.limitInRoom then - str = str..room.limitInRoom/1000 + str = str .. room.limitInRoom / 1000 end - if room.round==nil then - room.round=0 - end - - - --printlog("wwwwwwwwwww1111111111111111 ",room.round," ",room.times) - room_item.tex_round.text = room.status >=-1 and string.format('%s/%s', room.round, room.times) or "" + if room.round == nil then + room.round = 0 + end + + + --printlog("wwwwwwwwwww1111111111111111 ",room.round," ",room.times) + room_item.tex_round.text = room.status >= -1 and string.format('%s/%s', room.round, room.times) or "" local name = __getLayerName(self, room.pid) room_item.tex_gamename.text = name room_item.tex_limit.text = str @@ -212,7 +212,7 @@ local function __fillRoomItem(self, index, item, room) if config.isHidden and config.isHidden == 1 then isHidden = 1 end - end + end play.isHidden = isHidden end room_item.ctr_color.selectedIndex = play and play.deskId or room.color or 0 @@ -230,15 +230,14 @@ local function __fillRoomItem(self, index, item, room) local p = plist[i] if isHidden == 0 then p_head.tex_name.text = ViewUtil.stringEllipsis(p.nick) - p_head.tex_id.text = "ID:"..p.aid + p_head.tex_id.text = "ID:" .. p.aid ImageLoad.Load(p.portrait, btn_head._iconObject, self.class) - - if p.hp then - local str1="积分:" - local hp=p.hp/1000 - p_head.text_score.text=str1..hp - end - + + if p.hp then + local str1 = "积分:" + local hp = p.hp / 1000 + p_head.text_score.text = str1 .. hp + end else p_head.tex_name.text = "智能" p_head.tex_id.text = "防作弊" @@ -266,13 +265,13 @@ local function __fillRoomItem(self, index, item, room) p_item.visible = false end end - -- desk.touchable = false + -- desk.touchable = false desk.onClick:Set( function() if room.default or self.curGroup.lev == 3 then -- 房间点击:假房间 匹配,真房间 加入 if room.default or isHidden == 1 then - self:__startGame(room.id,room.pid, true, isHidden) + self:__startGame(room.id, room.pid, true, isHidden) else self:__joinRoom(roomid) end @@ -291,7 +290,7 @@ local function __fillRoomItem(self, index, item, room) function() riv:Dispose() if room.default or isHidden == 1 then - self:__startGame(room.id,room.pid, true, isHidden) + self:__startGame(room.id, room.pid, true, isHidden) else self:__joinRoom(roomid) end @@ -301,15 +300,15 @@ local function __fillRoomItem(self, index, item, room) function() local _curren_msg = MsgWindow.new( - self._root_view, - '确定解散该桌子吗?\r(解散该桌子没有任何结算信息,请谨慎操作)', - MsgWindow.MsgMode.OkAndCancel - ) + self._root_view, + '确定解散该桌子吗?\r(解散该桌子没有任何结算信息,请谨慎操作)', + MsgWindow.MsgMode.OkAndCancel + ) _curren_msg.onOk:Add( function() ViewUtil.ShowModalWait(self._root_view) local fgCtr = ControllerManager.GetController(NewGroupController) - + fgCtr:FG_RemoveRoom( self.curGroup.id, roomid, @@ -339,14 +338,13 @@ local function __fillRoomItem(self, index, item, room) self._view:AddChild(riv) riv:Center() end - - - local key = tostring(self.curGroup.id) + + + local key = tostring(self.curGroup.id) self.fg_info[key] = room.pid local filename = 'fginfo_' .. DataManager.SelfUser.account_id Utils.SaveLocalFile(filename, json.encode(self.fg_info)) - - end + end ) end @@ -369,14 +367,14 @@ local function __fillRoomData(self) local currentPlayID = self:GetSelectedPlayID() local currentGameID = self:GetSelectedGameID() - -- self.lst_layer.visible = currentGameID > 0 + -- self.lst_layer.visible = currentGameID > 0 --self.line1.visible = currentGameID > 0 if currentPlayID > 0 then --printlog("aaaaaaaaaaaaaaaaa11111111111111111111111111111111") -- 单个玩法 local rooms = self.curGroup:getPlay(currentPlayID).rooms local trooms = {} - for i=1,#rooms do + for i = 1, #rooms do local room = rooms[i] local play = self.curGroup:getPlay(room.pid) local isvip = 0 @@ -398,24 +396,21 @@ local function __fillRoomData(self) isHidden = 1 end end - play.isHidden = isHidden + play.isHidden = isHidden play.isvip = isvip - - - ----------- - if isvip == self._showVipRooms then - if isHidden == 1 then - if #room.plist == room.maxPlayers or self.curGroup.lev < 3 then - table.insert( trooms,room ) - end - else - table.insert( trooms,room ) - end - end - - + + + ----------- + if isvip == self._showVipRooms then + if isHidden == 1 then + if #room.plist == room.maxPlayers or self.curGroup.lev < 3 then + table.insert(trooms, room) + end + else + table.insert(trooms, room) + end + end end - end self.curRooms = membe_clone(trooms) @@ -430,33 +425,31 @@ local function __fillRoomData(self) if config.isvip and config.isvip == 1 then isvip = 1 end - end + end play.isvip = isvip - - ------ - if isvip == self._showVipRooms then - local hp=json.decode(play.hpData) - if hp and hp.maxRound then - room.times=hp.maxRound - end - - if hp and hp.limitInRoom then - room.limitInRoom=hp.limitInRoom - end - - - table.insert( self.curRooms,room ) - - end - ----- + + ------ + if isvip == self._showVipRooms then + local hp = json.decode(play.hpData) + if hp and hp.maxRound then + room.times = hp.maxRound + end + + if hp and hp.limitInRoom then + room.limitInRoom = hp.limitInRoom + end + + + table.insert(self.curRooms, room) + end + ----- end - else if currentGameID == 0 then --printlog("aaaaaaaaaaaaaaaaa222222222222222222222222222") local rooms = curGroup.rooms local trooms = {} - for i=1,#rooms do + for i = 1, #rooms do local room = rooms[i] local play = self.curGroup:getPlay(room.pid) local isvip = 0 @@ -478,28 +471,26 @@ local function __fillRoomData(self) isHidden = 1 end end - play.isHidden = isHidden + play.isHidden = isHidden play.isvip = isvip - - ----- - if isvip == self._showVipRooms then - if play.isHidden == 1 then - if #room.plist == room.maxPlayers or self.curGroup.lev < 3 then - table.insert( trooms,room ) - end - else - table.insert( trooms,room ) - end - end - + + ----- + if isvip == self._showVipRooms then + if play.isHidden == 1 then + if #room.plist == room.maxPlayers or self.curGroup.lev < 3 then + table.insert(trooms, room) + end + else + table.insert(trooms, room) + end + end end - end self.curRooms = membe_clone(trooms) - + for i = 1, #self.curGroup.playList do local defaultRoom = self.curGroup.default_rooms[i] - + local play = self.curGroup:getPlay(defaultRoom.pid) local isvip = 0 if play then @@ -510,25 +501,24 @@ local function __fillRoomData(self) if config.isvip and config.isvip == 1 then isvip = 1 end - end + end play.isvip = isvip end if isvip == self._showVipRooms then - local hp=json.decode(self.curGroup.playList[i].hpData) - defaultRoom.limitInRoom=hp.limitInRoom - if hp.maxRound then - defaultRoom.times=hp.maxRound - end - local totalNum=1 - if hp.tex_times_room then - totalNum=hp.tex_times_room/1000 - end - - for i=1,totalNum do - self.curRooms[#self.curRooms + 1] = defaultRoom - end - - end + local hp = json.decode(self.curGroup.playList[i].hpData) + defaultRoom.limitInRoom = hp.limitInRoom + if hp.maxRound then + defaultRoom.times = hp.maxRound + end + local totalNum = 1 + if hp.tex_times_room then + totalNum = hp.tex_times_room / 1000 + end + + for i = 1, totalNum do + self.curRooms[#self.curRooms + 1] = defaultRoom + end + end end else --printlog("aaaaaaaaaaaaaaaaa33333333333333333333333333333333") @@ -552,7 +542,7 @@ local function __fillRoomData(self) if config.isHidden and config.isHidden == 1 then isHidden = 1 end - end + end p_data.isvip = isvip p_data.isHidden = isHidden @@ -569,44 +559,42 @@ local function __fillRoomData(self) self.curRooms[#self.curRooms + 1] = tempRoom end end - end - - local hp=json.decode(p_data.hpData) - if hp and hp.maxRound then - self.curGroup.default_rooms[i].times=hp.maxRound - end - - if hp and hp.limitInRoom then - self.curGroup.default_rooms[i].limitInRoom=hp.limitInRoom - end - - local totalNum=1 - if hp and hp.tex_times_room then - totalNum=hp.tex_times_room/1000 - end - for j=1,totalNum do - self.curRooms[#self.curRooms + 1] = self.curGroup.default_rooms[i] - end - + end + + local hp = json.decode(p_data.hpData) + if hp and hp.maxRound then + self.curGroup.default_rooms[i].times = hp.maxRound + end + + if hp and hp.limitInRoom then + self.curGroup.default_rooms[i].limitInRoom = hp.limitInRoom + end + + local totalNum = 1 + if hp and hp.tex_times_room then + totalNum = hp.tex_times_room / 1000 + end + for j = 1, totalNum do + self.curRooms[#self.curRooms + 1] = self.curGroup.default_rooms[i] + end end end end end - - currentSelectPlay=self:GetSelectedPlayID() - table.sort(self.curRooms,SortRooms ) + + currentSelectPlay = self:GetSelectedPlayID() + table.sort(self.curRooms, SortRooms) list_offline = {} if self.curGroup.lev < 3 then self.lst_room.numItems = #self.curRooms else if self.curGroup.show_num > 0 and #self.curRooms > self.curGroup.show_num then - local tr = {} for j = 1, #self.curRooms do if #tr < self.curGroup.show_num or self.curRooms[j].default == true then - table.insert(tr,self.curRooms[j]) + table.insert(tr, self.curRooms[j]) end end @@ -614,8 +602,8 @@ local function __fillRoomData(self) end self.lst_room.numItems = #self.curRooms end - - + + -- if self._ctr_search.selectedIndex == 1 then -- self.lst_room_search:RemoveChildrenToPool() @@ -650,7 +638,7 @@ end function M:InitRoomInfoView() local room = self.roominfo.room if not room.default then - printlog("wwwwwwwwwww22222222222222222 ",room.round," ",room.times) + printlog("wwwwwwwwwww22222222222222222 ", room.round, " ", room.times) self.roominfo.view:GetChild('tex_round').text = string.format('(%s/%s)', room.round, room.times) local lst_player = self.roominfo.view:GetChild('lst_player') lst_player:RemoveChildrenToPool() @@ -694,7 +682,6 @@ local function __fillPlayItem(self, index, item) if (index == 0) then tex_game.text = __getLayerName(self, 0) else - pipeijoin.onClick:Add( function() local currentPlayID = self:GetSelectedPlayID() @@ -717,7 +704,7 @@ local function __fillPlayItem(self, index, item) end end - self:__startGame("",currentPlayID, false) + self:__startGame("", currentPlayID, false) end ) tex_game.text = __getLayerName(self, self.playIdList[index]) @@ -726,7 +713,6 @@ end local _iconMap = {} local function __fillExtendIcon(id, callback) - local File = System.IO.File local path = Application.persistentDataPath .. '/UserData/Icon' if not System.IO.Directory.Exists(path) then @@ -760,7 +746,7 @@ local function __fillExtendIcon(id, callback) local texture = UnityEngine.Texture2D(128, 128) texture:LoadImage(bytes) local ntexture = FairyGUI.NTexture(texture) - _iconMap[id] = {texture = texture, ntexture = ntexture} + _iconMap[id] = { texture = texture, ntexture = ntexture } callback(ntexture) end ) @@ -771,65 +757,64 @@ local function __fillExtendIcon(id, callback) local texture = UnityEngine.Texture2D(128, 128) texture:LoadImage(bytes) local ntexture = FairyGUI.NTexture(texture) - _iconMap[id] = {texture = texture, ntexture = ntexture} + _iconMap[id] = { texture = texture, ntexture = ntexture } callback(ntexture) end end end local function GetGameName(index) - if index==0 then return "全 部" end - local list = DataManager.SelfUser.games - for k,v in ipairs(list) do - if v.game_id==index then - return v.name - end - end - return "" + if index == 0 then return "全 部" end + local list = DataManager.SelfUser.games + for k, v in ipairs(list) do + if v.game_id == index then + return v.name + end + end + return "" end -- 玩法名字显示 local function __fillGameItem(self, index, item) - local gameName="" + local gameName = "" if (index == 0) then item.icon = 'ui://NewGroup/quyxtb' - gameName=GetGameName(0) - item:GetChild("n11").text=gameName - if self.currentGameItemName==nil then - item.icon = 'ui://NewGroup/quyxtb-1' - end + gameName = GetGameName(0) + item:GetChild("n11").text = gameName + if self.currentGameItemName == nil then + item.icon = 'ui://NewGroup/quyxtb-1' + end else local gameId = self.gameIdList[index] local config = ExtendManager.GetExtendConfig(gameId) local mode = config:GetGameInfo() - local iconName=mode:GetIconUrl1() + local iconName = mode:GetIconUrl1() item.icon = iconName - gameName=GetGameName(gameId) - item:GetChild("n11").text=gameName + gameName = GetGameName(gameId) + item:GetChild("n11").text = gameName end - - if item.icon==self.currentGameItemName then - item.icon=self.currentGameItemName.."-1" - item:GetChild("n11").text=gameName - end - item:GetChild("n22").text=index+1 - + + if item.icon == self.currentGameItemName then + item.icon = self.currentGameItemName .. "-1" + item:GetChild("n11").text = gameName + end + item:GetChild("n22").text = index + 1 end local function __analysePlayListData(self) self.playIdList = {} - DataManager.SelfUser.PlayLocalList={} - - local playName="playfaconfig"..self.curGroup.id - local json_data = Utils.LoadLocalFile(playName) + DataManager.SelfUser.PlayLocalList = {} + + local playName = "playfaconfig" .. self.curGroup.id + local json_data = Utils.LoadLocalFile(playName) if json_data then - local data = json.decode(json_data) - DataManager.SelfUser.PlayLocalList=data - end - - - + local data = json.decode(json_data) + DataManager.SelfUser.PlayLocalList = data + end + + + local count = 0 local curGroup = self.curGroup local gameid = self:GetSelectedGameID() @@ -843,25 +828,25 @@ local function __analysePlayListData(self) if config.isvip and config.isvip == 1 then isvip = 1 end - end + end p_data.isvip = isvip - - local isHasPlayC=true - --[[for k,v in pairs(DataManager.SelfUser.PlayLocalList) do + + local isHasPlayC = true + --[[for k,v in pairs(DataManager.SelfUser.PlayLocalList) do if tonumber(k)==p_data.id then isHasPlayC=v end end--]] - - if (gameid == 0 or p_data.gameId == gameid) and isHasPlayC and isvip == self._showVipRooms then + + if (gameid == 0 or p_data.gameId == gameid) and isHasPlayC and isvip == self._showVipRooms then count = count + 1 self.playIdList[count] = p_data.id end end local lst_layer = self.lst_layer - -- printlog("添加玩法====>>>>",count) - -- pt(curGroup.playList) + -- printlog("添加玩法====>>>>",count) + -- pt(curGroup.playList) lst_layer.numItems = count + 1 end @@ -881,7 +866,7 @@ local function __analyseGameListData(self) if config.isvip and config.isvip == 1 then isvip = 1 end - end + end p_data.isvip = isvip if isvip == self._showVipRooms then @@ -891,10 +876,10 @@ local function __analyseGameListData(self) existed = true end end - + if existed == false then self.gameIdList[#self.gameIdList + 1] = p_data.gameId - end + end end end @@ -934,11 +919,11 @@ function M:InitView(url) -- local btndel = self._view:GetChild("btn_del") -- local texroomid = self._view:GetChild('tex_roomid') - - - + + + -- btndel.onClick:Set( - + -- function() -- local delroomid -- delroomid = (texroomid.text) or 0 @@ -955,7 +940,7 @@ function M:InitView(url) -- ) -- _curren_msg.onOk:Add( -- function() - + -- ViewUtil.ShowModalWait(self._root_view) -- local fgCtr = ControllerManager.GetController(NewGroupController) -- fgCtr:FG_RemoveRoom( @@ -982,7 +967,7 @@ function M:InitView(url) - self._view:GetChild('tex_id').text = "ID:"..self.curGroup.id + self._view:GetChild('tex_id').text = "ID:" .. self.curGroup.id self._view:GetChild('tex_name').text = self.curGroup.name @@ -1019,14 +1004,14 @@ function M:InitView(url) end -- local btn_remit = self._view:GetChild('btn_remit') - -- btn_remit.visible = false + -- btn_remit.visible = false self.lst_game.onClickItem:Add( function(pas) - if self.currentSelectItem == pas.data then return end - local name=pas.data.icon + if self.currentSelectItem == pas.data then return end + local name = pas.data.icon self.currentSelectItem = pas.data - self.currentGameItemName=name + self.currentGameItemName = name self.lst_layer.selectedIndex = 0 self:__refreshPay() __analyseGameListData(self) @@ -1034,22 +1019,22 @@ function M:InitView(url) __fillRoomData(self) end ) - -- self.line1 = self._view:GetChild('line1') + -- self.line1 = self._view:GetChild('line1') --self.line1.visible = false self.lst_layer = self._view:GetChild('lst_layer') self.lst_layer:SetVirtual() self.lst_layer.itemRenderer = function(index, item) __fillPlayItem(self, index, item) --if index>0 then - -- __fillPlayItem(self, index, item) + -- __fillPlayItem(self, index, item) --else - -- item.width = 0 - -- item.height = 0 - -- item.visible = false - -- end + -- item.width = 0 + -- item.height = 0 + -- item.visible = false + -- end end - + self.lst_layer.onClickItem:Add( function() @@ -1060,10 +1045,10 @@ function M:InitView(url) local btn_quanbu = self._view:GetChild('btn_quanbu') btn_quanbu.onClick:Set( - function () - self.lst_layer.selectedIndex=0 + function() + self.lst_layer.selectedIndex = 0 self:__loadPlayData() - end + end ) @@ -1092,12 +1077,12 @@ function M:InitView(url) btn_start.onClick:Set( function() local pid = self.fg_info[tostring(self.curGroup.id)] - + if pid == 0 then ViewUtil.ErrorTip(nil, '没有选择玩法') return end - self:__startGame("",pid, false) + self:__startGame("", pid, false) end ) @@ -1105,7 +1090,6 @@ function M:InitView(url) local btn_start2 = self._view:GetChild('btn_start2') btn_start2.onClick:Set( function() - local currentPlayID = self:GetSelectedPlayID() if currentPlayID == 0 then if self.lst_layer.selectedIndex == 0 and self.lst_game.selectedIndex > 0 then @@ -1126,53 +1110,52 @@ function M:InitView(url) end end - self:__startGame("",currentPlayID, false) + self:__startGame("", currentPlayID, false) end ) -- 选择玩法按钮 local btn_choose = self._view:GetChild('btn_choose') btn_choose.onClick:Set( - function () - self.lstgameVisible = not self.lstgameVisible - if (self.lstgameVisible) then - self.lst_game:TweenMove(Vector2.New(3,100), 0.3) - else - self.lst_game:TweenMove(Vector2.New(3,760), 0.3) - end - - end - -- function() - -- local sgv = - -- GroupSetDefaultGameView.new( - -- self.curGroup.id, - -- self._root_view, - -- function(num) - -- if num == 0 then - -- return - -- end - -- local pid = 0 - -- pid = self.curGroup.playList[num].id - -- btn_choose:GetChild('tex_gamename').text = __getLayerName(self, pid) - -- btn_choose:GetController('null').selectedIndex = 0 - -- local key = tostring(self.curGroup.id) - -- self.fg_info[key] = pid - -- local filename = 'fginfo_' .. DataManager.SelfUser.account_id - -- Utils.SaveLocalFile(filename, json.encode(self.fg_info)) - -- end - -- ) - -- local tem = self.fg_info[tostring(self.curGroup.id)] - -- local play_index = self.curGroup:getPlayIndex(tem) - -- if play_index == -1 then - -- play_index = 1 - -- end - - -- local setCallBackFunc=function() - -- __analysePlayListData(self) - -- end - -- sgv:FillData(self.curGroup.playList, play_index,setCallBackFunc) - -- sgv:Show() - -- end + function() + self.lstgameVisible = not self.lstgameVisible + if (self.lstgameVisible) then + self.lst_game:TweenMove(Vector2.New(3, 100), 0.3) + else + self.lst_game:TweenMove(Vector2.New(3, 760), 0.3) + end + end + -- function() + -- local sgv = + -- GroupSetDefaultGameView.new( + -- self.curGroup.id, + -- self._root_view, + -- function(num) + -- if num == 0 then + -- return + -- end + -- local pid = 0 + -- pid = self.curGroup.playList[num].id + -- btn_choose:GetChild('tex_gamename').text = __getLayerName(self, pid) + -- btn_choose:GetController('null').selectedIndex = 0 + -- local key = tostring(self.curGroup.id) + -- self.fg_info[key] = pid + -- local filename = 'fginfo_' .. DataManager.SelfUser.account_id + -- Utils.SaveLocalFile(filename, json.encode(self.fg_info)) + -- end + -- ) + -- local tem = self.fg_info[tostring(self.curGroup.id)] + -- local play_index = self.curGroup:getPlayIndex(tem) + -- if play_index == -1 then + -- play_index = 1 + -- end + + -- local setCallBackFunc=function() + -- __analysePlayListData(self) + -- end + -- sgv:FillData(self.curGroup.playList, play_index,setCallBackFunc) + -- sgv:Show() + -- end ) local btn_close = self._view:GetChild('btn_close') @@ -1196,7 +1179,7 @@ function M:InitView(url) -- end -- ) -- return - -- end + -- end -- self._view:GetController('pipei').selectedIndex = 0 -- end -- ) @@ -1229,7 +1212,7 @@ function M:InitView(url) self:__loadGroupData() self:__refreshManager() UpdateBeat:Add(self.__onUpdate, self) - self._view.visible=false + self._view.visible = false end function M:__saveLastData() @@ -1251,7 +1234,7 @@ function M:__loadLastData() table.insert(self.gameIdList, t.gameId) end table.insert(self.playIdList, t.id) - local room = {maxPlayers = t.maxPlayers, status = 0, default = true, pid = t.id, color = t.deskId} + local room = { maxPlayers = t.maxPlayers, status = 0, default = true, pid = t.id, color = t.deskId } table.insert(self.curRooms, room) self.playNames[t.id] = t.name end @@ -1272,13 +1255,13 @@ function M:__onUpdate() if self._pipeiTime and self._pipeiTime > 0 then local deltaTime = Time.deltaTime self._pipeiTime = self._pipeiTime - deltaTime - self._pipeiTime = math.max( self._pipeiTime,0 ) + self._pipeiTime = math.max(self._pipeiTime, 0) if self._pipeiTime == 0 then - self._view:GetChild('node_matching'):GetChild('text_time').text = "当前排位时间较长,请耐心等待..." - self._view:GetChild('node_matching'):GetController('quxiao').selectedIndex = 1 + self._view:GetChild('node_matching'):GetChild('text_time').text = "当前排位时间较长,请耐心等待..." + self._view:GetChild('node_matching'):GetController('quxiao').selectedIndex = 1 else local time = math.floor(self._pipeiTime) - self._view:GetChild('node_matching'):GetChild('text_time').text = "玩家排位中,".. time .."秒后可退出..." + self._view:GetChild('node_matching'):GetChild('text_time').text = "玩家排位中," .. time .. "秒后可退出..." end end if self.__join_room then @@ -1346,7 +1329,7 @@ function M:__joinRoom(room_id) RestartGame() return end - + if response.ReturnCode == -2 then self:__joinRoom(room_id) return @@ -1368,7 +1351,7 @@ function M:__joinRoom(room_id) ) end ) - return + return end end roomCtr:PublicJoinRoom( @@ -1376,8 +1359,8 @@ function M:__joinRoom(room_id) room_id, false, function(response) - printlog("进入房间返回事件==========》》》") - pt(response) + printlog("进入房间返回事件==========》》》") + pt(response) if (response.ReturnCode == -1) then ViewUtil.CloseModalWait('join_room') RestartGame() @@ -1405,7 +1388,7 @@ function M:__joinRoom(room_id) ) end -function M:__joinRoom_match(roomid,pid, is_null, isHidden, callback) +function M:__joinRoom_match(roomid, pid, is_null, isHidden, callback) if isHidden == nil then isHidden = 0 local play = self.curGroup:getPlay(pid) @@ -1417,8 +1400,8 @@ function M:__joinRoom_match(roomid,pid, is_null, isHidden, callback) if config.isHidden and config.isHidden == 1 then isHidden = 1 end - end - play.isHidden = isHidden + end + play.isHidden = isHidden end end if isHidden == 1 then @@ -1427,7 +1410,7 @@ function M:__joinRoom_match(roomid,pid, is_null, isHidden, callback) DataManager.SelfUser.location = Location.new() end if DataManager.SelfUser.location:Location2String() == "" then - -- if DataManager.SelfUser.location:Location2String() == "" then + -- if DataManager.SelfUser.location:Location2String() == "" then ViewUtil.ErrorTip(nil, "没有打开GPS定位,不能参与该游戏") get_gps() return @@ -1452,7 +1435,7 @@ function M:__joinRoom_match(roomid,pid, is_null, isHidden, callback) RestartGame() return end - + if response.ReturnCode ~= 0 then self._view:GetController('pipei').selectedIndex = 0 callback(response.ReturnCode) @@ -1475,9 +1458,9 @@ function M:__joinRoom_match(roomid,pid, is_null, isHidden, callback) end, self.curGroup.id, pid - ) + ) end) - + return end @@ -1567,29 +1550,30 @@ function M:_evtUpdateMsg() self:_setHongDian(true) end end + function M:_setHongDian(isShow) --红点提示 local member_tips = self._view:GetChild('member_tips') member_tips.visible = isShow end + function M:_evtInvited(...) - local arg = {...} + local arg = { ... } local data = arg[1] local imv = FGInvitedMsgView.new( - self._root_view, - self.curGroup.id, - function(roomid) - self:__joinRoom(roomid) - end - ) + self._root_view, + self.curGroup.id, + function(roomid) + self:__joinRoom(roomid) + end + ) imv:FillData(data) imv:Show() end -- 更新牌友圈事件 function M:_evtUpdateGroup(...) - -- local btn_remit = self._view:GetChild('btn_remit') -- local option = self.curGroup.option or 0 @@ -1628,24 +1612,24 @@ function M:__refreshManager() end ) local btn_partner = self._view:GetChild('btn_partner') - btn_partner.onClick:Set( + btn_partner.onClick:Set( function() - --print("成员..........................................") + ---- print("成员..........................................") if not self.mng_view3 then self.mng_view3 = GroupManagerView.new(self._root_view, self.curGroup.id, 5) - self.mng_view3:SetCurrentGroupInfoViewIns(function () - self:OnclickMember() - end) + self.mng_view3:SetCurrentGroupInfoViewIns(function() + self:OnclickMember() + end) end self.mng_view3:Show() -- self:SetRoomListVisible(false) end ) - + local btn_play = self._view:GetChild('btn_play') btn_play.onClick:Set(function() - local gl_view =GroupMngGameListView.new(self.curGroup.id) + local gl_view = GroupMngGameListView.new(self.curGroup.id) gl_view:Show() -- self:SetRoomListVisible(false) end) @@ -1662,9 +1646,8 @@ function M:__refreshManager() ) end - function M:OnclickMember() - if not self.mng_view3 then + if not self.mng_view3 then self.mng_view3 = GroupManagerView.new(self._root_view, self.curGroup.id, 5) end self.mng_view3:Show() @@ -1689,18 +1672,18 @@ function M:__ShowNotice() end self._tw_notice = DSTween.To( - 0, - 1, - dur_time, - function(value) - tex_notice.x = start_x - speed_x * value * dur_time - end - ):OnComplete( - function() - self._tw_notice = nil - self:__ShowNotice() - end - ) + 0, + 1, + dur_time, + function(value) + tex_notice.x = start_x - speed_x * value * dur_time + end + ):OnComplete( + function() + self._tw_notice = nil + self:__ShowNotice() + end + ) end -- 显示玩法信息 @@ -1720,7 +1703,7 @@ function M:__loadGroupData() curGroup.update_room = false curGroup.update_info = false curGroup.update_joins = false - ViewUtil.ShowModalWait(self._root_view,"正在进入牌友圈,请稍等...") + ViewUtil.ShowModalWait(self._root_view, "正在进入牌友圈,请稍等...") local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_EnterGroup( curGroup.id, @@ -1728,13 +1711,13 @@ function M:__loadGroupData() -- if self._is_destroy then -- return -- end - ViewUtil.CloseModalWait() + ViewUtil.CloseModalWait() if res.ReturnCode ~= 0 then - --self._view.visible=false - --ViewUtil.ErrorTip(res.ReturnCode, "获取圈子数据失败") + --self._view.visible=false + --ViewUtil.ErrorTip(res.ReturnCode, "获取圈子数据失败") else - self._view.visible=true - self:Show() + self._view.visible = true + self:Show() self:__saveLastData() local mgr_ctr = ControllerManager.GetController(GroupMgrController) mgr_ctr:AddEventListener(GroupMgrEvent.AddPlay, handler(self, self._evtAddPlay)) @@ -1756,23 +1739,23 @@ function M:__loadGroupData() local ctr_msg = self._view:GetController('msg') ctr_msg.selectedIndex = 1 end - + local btn_vip = self._view:GetChild("btn_vip") if self.curGroup.isvip == 1 then - local vip = self.fg_info[tostring(self.curGroup.id).."vip"] or 0 + local vip = self.fg_info[tostring(self.curGroup.id) .. "vip"] or 0 self._showVipRooms = vip - btn_vip:GetController("vip").selectedIndex = math.abs( self._showVipRooms - 1) - btn_vip.onClick:Set(function () + btn_vip:GetController("vip").selectedIndex = math.abs(self._showVipRooms - 1) + btn_vip.onClick:Set(function() btn_vip:GetController("vip").selectedIndex = self._showVipRooms - self._showVipRooms = math.abs( self._showVipRooms - 1 ) + self._showVipRooms = math.abs(self._showVipRooms - 1) self:_evtUpdatePlay() local key = tostring(self.curGroup.id) .. "vip" self.fg_info[key] = self._showVipRooms local filename = 'fginfo_' .. DataManager.SelfUser.account_id - Utils.SaveLocalFile(filename, json.encode(self.fg_info)) - end) + Utils.SaveLocalFile(filename, json.encode(self.fg_info)) + end) end - + -- 玩法列表初始化 __analyseGameListData(self) __analysePlayListData(self) @@ -1800,14 +1783,14 @@ function M:__loadGroupData() end ) local btn_invite = self._view:GetChild('btn_invite') - btn_invite.displayObject.gameObject:SetActive(false) + btn_invite.displayObject.gameObject:SetActive(false) --[[btn_invite.onClick:Set(function() if not self.mng_view3 then self.mng_view3 = GroupManagerView.new(self._root_view, self.curGroup.id, 3) end self.mng_view3:Show(1) end)--]] - + -- local btn_rank = self._view:GetChild("btn_rank") -- btn_rank.onClick:Set(function() -- local rv = GroupRank.new(self._root_view, self.curGroup.id) @@ -1846,22 +1829,23 @@ function M:__loadGroupData() btn_mail.selected = false end ) - gmv:Show() + gmv:Show() end ) local btn_bxx = self._view:GetChild('btn_bxx') btn_bxx.onClick:Set( function() - local ctrNum=1 - -- if self.curGroup.lev==3 and self.curGroup.partnerLev>0 or self.curGroup.lev==1 or self.curGroup.lev==2 then - -- ctrNum=2 - -- end - if self.curGroup.lev==1 then - ctrNum=2 - end - ctrNum=2 - local gmv = GroupMngFagPackView.new(self.curGroup.id, self._root_view,ctrNum,DataManager.SelfUser.account_id) + local ctrNum = 1 + -- if self.curGroup.lev==3 and self.curGroup.partnerLev>0 or self.curGroup.lev==1 or self.curGroup.lev==2 then + -- ctrNum=2 + -- end + if self.curGroup.lev == 1 then + ctrNum = 2 + end + ctrNum = 2 + local gmv = GroupMngFagPackView.new(self.curGroup.id, self._root_view, ctrNum, + DataManager.SelfUser.account_id) gmv:SetCallback( function() btn_bxx.selected = false @@ -1876,7 +1860,7 @@ function M:__loadGroupData() end -- 匹配游戏 -function M:__startGame(roomid,pid, is_null,isHidden, callback) +function M:__startGame(roomid, pid, is_null, isHidden, callback) ViewUtil.ShowModalWait(self._root_view, '正在加入游戏...', 'join_room') local _gameCtrl = ControllerManager.GetController(GameController) local _currentCtrl = ControllerManager.GetCurrenController() @@ -1890,7 +1874,7 @@ function M:__startGame(roomid,pid, is_null,isHidden, callback) isHidden, function(code) if code == -2 then - self:__startGame(roomid,pid, is_null, isHidden, callback) + self:__startGame(roomid, pid, is_null, isHidden, callback) elseif code ~= 0 then ViewUtil.ErrorMsg(self._root_view, code, '进入房间失败') ViewUtil.CloseModalWait('join_room') @@ -1925,7 +1909,7 @@ end -- 显示各玩法体力值信息 function M:__refreshPay() - --printlog("1111111111111111111111111111",self.curGroup.hp) + --printlog("1111111111111111111111111111",self.curGroup.hp) self.tex_fag.text = '' .. d2ad(self.curGroup.hp or 0) -- self.tex_diamo.text = self.curGroup.diamo @@ -1955,11 +1939,11 @@ function M:__share() local str = string.format('【%s】 邀请您加入!', tem.name) local url = string.format( - '%s?type=t1&playerId=%s&groupId=%s', - GetGameInfo('share_group_link'), - DataManager.SelfUser.account_id, - tem.id - ) + '%s?type=t1&playerId=%s&groupId=%s', + GetGameInfo('share_group_link'), + DataManager.SelfUser.account_id, + tem.id + ) local json_data = {} json_data['title'] = string.format('大联盟号【%s】', tem.id) local mediaObject = {} @@ -1980,15 +1964,16 @@ function M:showPipei(play) end self._pipeiTime = 20 end + function M:hidePipei() - --print("hidePipei=============") - --print(self._view) - --print(self._view:GetController('pipei')) - if self._view:GetController('pipei') then - self._view:GetController('pipei').selectedIndex = 0 - end - + ---- print("hidePipei=============") + ---- print(self._view) + ---- print(self._view:GetController('pipei')) + if self._view:GetController('pipei') then + self._view:GetController('pipei').selectedIndex = 0 + end end + function M:SetCallBack(callback) self._callback = nil self._callback = callback @@ -2055,4 +2040,3 @@ function M:Destroy() end return M - diff --git a/lua_probject/base_project/Game/View/NewGroup/GroupMainView.lua b/lua_probject/base_project/Game/View/NewGroup/GroupMainView.lua index 57b9fb98..293264f4 100644 --- a/lua_probject/base_project/Game/View/NewGroup/GroupMainView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/GroupMainView.lua @@ -8,9 +8,9 @@ local GroupMainView = {} local M = GroupMainView -function GroupMainView.new(main_view, root_view,par_veiw) - --print(debug.traceback()) - local self = setmetatable({}, {__index = M}) +function GroupMainView.new(main_view, root_view, par_veiw) + ---- print(debug.traceback()) + local self = setmetatable({}, { __index = M }) self.class = 'GroupMainView' UIPackage.AddPackage('base/newgroup/ui/NewGroup') self._view = main_view @@ -21,7 +21,7 @@ function GroupMainView.new(main_view, root_view,par_veiw) end function M:InitView(url) - --print(url) + ---- print(url) -- BlurView(self._view:GetChild("bg"),true) if DataManager.SelfUser.agent > 0 then self._view:GetController('agent').selectedIndex = 1 @@ -37,7 +37,7 @@ function M:InitView(url) cgv:Show() cgv:SetCallback(function(name, pay_type, fg_type) ViewUtil.ShowModalWait(cgv._root_view) - fgCtr:FG_CreateGroup(name,pay_type,fg_type,function(res) + fgCtr:FG_CreateGroup(name, pay_type, fg_type, function(res) ViewUtil.CloseModalWait() if self._is_destroy then return @@ -53,7 +53,7 @@ function M:InitView(url) end) self.btn_joingroup = self._par_veiw:GetChild('btn_join_group') - self.btn_joingroup.displayObject.gameObject:SetActive(false) + self.btn_joingroup.displayObject.gameObject:SetActive(false) --[[self.btn_joingroup.onClick:Set(function() local groups = DataManager.groups.groupList if #groups == 0 then @@ -131,23 +131,22 @@ end function M:DEnterGroup() local groups = DataManager.groups.groupList - if #groups == 0 then - --local jgv = JoinGroupView.new(self._root_view) - --jgv:Show() - else - local info = GroupInfoView.new(groups[1], self.fg_info) - self._groupInfoView = info - info:SetCallBack(function() - self._groupInfoView = nil - self:Show() - self._view.visible = true - end) - --info:Show() - --self._view.visible = false - end + if #groups == 0 then + --local jgv = JoinGroupView.new(self._root_view) + --jgv:Show() + else + local info = GroupInfoView.new(groups[1], self.fg_info) + self._groupInfoView = info + info:SetCallBack(function() + self._groupInfoView = nil + self:Show() + self._view.visible = true + end) + --info:Show() + --self._view.visible = false + end end - local function SortGroups(a, b) local sort_a = 0 local sort_b = 0 @@ -157,13 +156,13 @@ local function SortGroups(a, b) return sort_a > sort_b end -function M:__fill_item(item,group) +function M:__fill_item(item, group) item:GetChild('tex_name').text = group.name - item:GetChild('tex_id').text = "ID:".. group.id + item:GetChild('tex_id').text = "ID:" .. group.id local p_num = group.total_member_num item:GetChild('tex_p_num').text = p_num > 99 and '99+' or p_num - if group.lev < 3 then + if group.lev < 3 then if group.lev == 1 then item:GetChild('tex_room_num').text = group.room_num else @@ -171,12 +170,12 @@ function M:__fill_item(item,group) end else if group.show_num > 0 and group.room_num > group.show_num then - item:GetChild('tex_room_num').text = group.show_num > 99 and '99+' or group.show_num--group.show_num + item:GetChild('tex_room_num').text = group.show_num > 99 and '99+' or group.show_num --group.show_num else item:GetChild('tex_room_num').text = group.room_num > 99 and '99+' or group.room_num end end - + local btn_head = item:GetChild('btn_head') btn_head.icon = 'ui://Common/Head0' ImageLoad.Load(group.o_portrait, btn_head._iconObject, self.class) @@ -192,7 +191,7 @@ function M:FillData() local new_info = {} for i = 1, #groups do local key = tostring(groups[i].id) - local key1 = tostring(groups[i].id).."vip" + local key1 = tostring(groups[i].id) .. "vip" if not fg_info[key] then new_info[key] = 0 if not fg_info_changed then @@ -220,7 +219,7 @@ function M:FillData() else self.btn_joingroup:GetController("info").selectedIndex = 1 ctr_empty_group.selectedIndex = 0 - self:__fill_item(self.btn_joingroup,groups[1]) + self:__fill_item(self.btn_joingroup, groups[1]) end local lst_group = self._view:GetChild('lst_group') @@ -230,7 +229,7 @@ function M:FillData() local item = lst_group:AddItemFromPool() item.data = group - self:__fill_item(item,group) + self:__fill_item(item, group) local btn_top = item:GetChild('btn_top') local ctr_select = btn_top:GetController('select') @@ -240,7 +239,7 @@ function M:FillData() context:StopPropagation() local fgCtr = ControllerManager.GetController(NewGroupController) ViewUtil.ShowModalWait(self._root_view) - fgCtr:FG_TopGroup(group.id,ctr_select.selectedIndex == 0,function(res) + fgCtr:FG_TopGroup(group.id, ctr_select.selectedIndex == 0, function(res) ViewUtil.CloseModalWait() if self._is_destroy then return @@ -274,7 +273,7 @@ function M:EnterGroup(fg_id) --self._view.visible = false end -function M:Show(fg_id,callback) +function M:Show(fg_id, callback) local fgCtr1 = ControllerManager.GetController(NewGroupController) fgCtr1:FG_GroupList(function(res) if self._is_destroy then @@ -284,17 +283,16 @@ function M:Show(fg_id,callback) self:FillData() if fg_id then self:EnterGroup(fg_id) - else - if callback then - callback(0) - end + else + if callback then + callback(0) + end + end + else + if callback then + callback(-1) end - else - if callback then - callback(-1) - end end - end) end diff --git a/lua_probject/base_project/Game/View/NewGroup/GroupManagerView.lua b/lua_probject/base_project/Game/View/NewGroup/GroupManagerView.lua index 5a83267a..4d575189 100644 --- a/lua_probject/base_project/Game/View/NewGroup/GroupManagerView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/GroupManagerView.lua @@ -6,8 +6,8 @@ local GroupManagerView = {} local M = GroupManagerView function GroupManagerView.new(blur_view, gid, btn_type, callback) - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "GroupManagerView" -- self._close_destroy = true self._put_map = false @@ -25,8 +25,8 @@ end -- 获取界面配置 local function getPageConfig(id) - --pt(MngPageConfig.PageList) - for i=1,#MngPageConfig.PageList do + --pt(MngPageConfig.PageList) + for i = 1, #MngPageConfig.PageList do local tem = MngPageConfig.PageList[i] if tem.id == id then return tem @@ -35,7 +35,7 @@ local function getPageConfig(id) end function M:init(url, btn_type) - BaseWindow.init(self,url) + BaseWindow.init(self, url) self.titleTxt = self._view:GetChild("n79") -- if btn_type == 2 then -- self._view:GetChild("n0"):GetChild("icon").url = "ui://m7iejg46p41ohx8" @@ -57,7 +57,7 @@ function M:init(url, btn_type) -- 初始化标题列表 for i = 1, #self.page_config do - -- print("page_config:"..self.page_config[i]) + -- -- print("page_config:"..self.page_config[i]) local page = getPageConfig(self.page_config[i]) --如果界面无show_key,或圈子中对应的key为true才显示界面 if not page.show_key or (page.show_key and group[page.show_key]) then @@ -89,9 +89,9 @@ function M:init(url, btn_type) -- gmsv._view.width = GRoot.inst.width -300 - 2 * offset -- gmsv._view.height = GRoot.inst.height -- gmsv._view.x = offset - + -- end) - -- 所有子界面加载点 + -- 所有子界面加载点 local anchor = self._view:GetChild("anchor") -- 初始界面 local first_page_config = getPageConfig(self.page_config[1]) @@ -104,21 +104,21 @@ function M:init(url, btn_type) --gmsv._view:AddRelation(anchor, RelationType.Size) local offset = get_offset(self._full_offset) gmsv._view.width = GRoot.inst.width - 2 * offset - first_page_config.anchorOffset - gmsv._view.height = GRoot.inst.height - gmsv._view.x = 0--offset + gmsv._view.height = GRoot.inst.height + gmsv._view.x = 0 --offset -- first_page_config = getPageConfig(self.page_config[2]) -- gmsv = first_page_config.view.new(self.group_id, self._root_view) -- self._view_map[2] = gmsv -- gmsv.id = first_page_config.id -- gmsv._view.visible = false - + -- anchor:AddChild(gmsv._view) -- gmsv._view:AddRelation(anchor, RelationType.Size) - - + + -- if first_page_config.refresh then gmsv:initData() end -- if #self.page_config == 1 then @@ -138,50 +138,47 @@ function M:init(url, btn_type) local index = self.ctr_index.selectedIndex local page_info = getPageConfig(self.page_config[index + 1]) if not self._view_map[index + 1] then - local tem = page_info.view.new(self.group_id, self._root_view) - - -- anchor:AddRelation(self._root_view, RelationType.Size,true) - --tem._view:Center(true) - - --print("222222222222222",anchor._view) - anchor:AddChild(tem._view) + + -- anchor:AddRelation(self._root_view, RelationType.Size,true) + --tem._view:Center(true) + + ---- print("222222222222222",anchor._view) + anchor:AddChild(tem._view) -- tem._view.parent = anchor - + local offset = get_offset(self._full_offset) tem._view.width = GRoot.inst.width - 2 * offset - page_info.anchorOffset - tem._view.height = GRoot.inst.height - tem._view.x = 0--offset - --tem._view:AddRelation(self._root_view, RelationType.Size) + tem._view.height = GRoot.inst.height + tem._view.x = 0 --offset + --tem._view:AddRelation(self._root_view, RelationType.Size) -- tem._view:MakeFullScreen() - + tem.id = page_info.id self._view_map[index + 1] = tem -- - -- anchor:SetBoundsChangedFlag() - -- anchor:EnsureBoundsCorrect() + -- anchor:SetBoundsChangedFlag() + -- anchor:EnsureBoundsCorrect() -- tem._view:RemoveRelation(anchor, RelationType.Size) - --tem._view:AddRelation(anchor, RelationType.Size) + --tem._view:AddRelation(anchor, RelationType.Size) else --self._view_map[index + 1]._view:AddRelation(anchor, RelationType.Size) - anchor:AddChild(self._view_map[index + 1]._view) + anchor:AddChild(self._view_map[index + 1]._view) end - + --self._view:AddRelation(anchor, RelationType.Size) -- 如果refresh为true,重新加载界面时执行初始化数据方法initData - if page_info.refresh then - self._view_map[index + 1]:initData() + if page_info.refresh then + self._view_map[index + 1]:initData() end self.titleTxt.text = page_info.title end) end - function M:SetCurrentGroupInfoViewIns(groupInfoViewCallBack) - self.groupInfoViewCallBack=groupInfoViewCallBack + self.groupInfoViewCallBack = groupInfoViewCallBack end - -- 获取指定ID的页面 function M:GetPageByID(id) for i, v in pairs(self._view_map) do @@ -221,7 +218,7 @@ end -- quick_access_id 是快速访问标志,打开对应id的页面 function M:Show(quick_access_id) local index = self.ctr_index.selectedIndex - printlog("index+1index+1index+1index+1 ",index+1) + printlog("index+1index+1index+1index+1 ", index + 1) if not quick_access_id then local page_info = getPageConfig(self.page_config[index + 1]) if page_info.refresh then self._view_map[index + 1]:initData() end @@ -246,4 +243,4 @@ function M:Show(quick_access_id) BaseWindow.Show(self) end -return M \ No newline at end of file +return M diff --git a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupGameSettingView.lua b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupGameSettingView.lua index 30dc4aeb..b0f5e3e6 100644 --- a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupGameSettingView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupGameSettingView.lua @@ -456,7 +456,7 @@ function M:FillFagData() local tex_name = self._view:GetChild("tex_name") local name = tex_name.text - print("jefe:") + -- print("jefe:") pt(self.hpData) local fgCtr = ControllerManager.GetController(NewGroupController) @@ -469,7 +469,7 @@ function M:FillFagData() return end ViewUtil.CloseModalWait() - --print("======新增玩法=============") + ---- print("======新增玩法=============") --pt(res) if res.ReturnCode == 0 then local play = {} @@ -510,7 +510,7 @@ function M:FillFagData() return end ViewUtil.CloseModalWait() - --print("======修改玩法=============") + ---- print("======修改玩法=============") --pt(res) if res.ReturnCode == 0 then local play = {} diff --git a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberFagLogView.lua b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberFagLogView.lua index b0972386..2903ca6c 100644 --- a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberFagLogView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberFagLogView.lua @@ -5,8 +5,8 @@ local GroupMemberFagLogView = {} local M = GroupMemberFagLogView function GroupMemberFagLogView.new(group_id, member, not_manager) - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "GroupMemberFagLogView" self._close_destroy = true -- self._blur_view = blur_view @@ -15,7 +15,7 @@ function GroupMemberFagLogView.new(group_id, member, not_manager) self._full = true self._animation = false self.group_id = group_id - self.hp_log = {} + self.hp_log = {} self.daily_count = {} self.not_manager = not_manager self._full = true @@ -25,7 +25,7 @@ function GroupMemberFagLogView.new(group_id, member, not_manager) end function M:init(url) - BaseWindow.init(self,url) + BaseWindow.init(self, url) local btn_close = self._view:GetChild("btn_close") btn_close.onClick:Set(function() @@ -33,26 +33,25 @@ function M:init(url) end) for i = 1, 8 do - local tem = math.pow(2, i - 1) - local btn_filter = self._view:GetChild("btn_filter" .. tem) - if btn_filter then - btn_filter.onClick:Set(function() - self.hp_log = {} + local tem = math.pow(2, i - 1) + local btn_filter = self._view:GetChild("btn_filter" .. tem) + if btn_filter then + btn_filter.onClick:Set(function() + self.hp_log = {} self.m_index = 0 - self.lst_fag.numItems = 0 - self:GetData(0) - end) - end + self.lst_fag.numItems = 0 + self:GetData(0) + end) + end end self.lst_fag = self._view:GetChild("lst_fag") - self.lst_fag:SetVirtual() + self.lst_fag:SetVirtual() self.lst_fag.itemRenderer = function(index, obj) - self:OnRenderItem(index, obj) - end + self:OnRenderItem(index, obj) + end self.lst_fag.scrollPane.onPullUpRelease:Set(function() - self:GetData(self.lst_fag.numItems+self.m_index) - + self:GetData(self.lst_fag.numItems + self.m_index) end) if not self.not_manager then self._view:GetController("manager").selectedIndex = 1 @@ -66,7 +65,7 @@ function M:init(url) self.lst_daily_count:SetVirtual() self.lst_daily_count.itemRenderer = function(index, obj) self:OnRenderDailyItem(index, obj) - end + end self.ctr_index = self._view:GetController("index") self.ctr_index.onChanged:Set(function() @@ -75,7 +74,8 @@ function M:init(url) end end) - self.time_panel = TimeSettingPanel.new(self._view, self._view:GetChild("btn_date1"), self._view:GetChild("btn_date2"), -308, 0) + self.time_panel = TimeSettingPanel.new(self._view, self._view:GetChild("btn_date1"), self._view:GetChild("btn_date2"), + -308, 0) self.begin_time, self.end_time = self.time_panel:GetDate() self._view:GetChild("btn_search").onClick:Set(function() @@ -90,21 +90,21 @@ end -- 获取过滤值,根据多选框计算 function M:GetFilter() - local filter = 0 + local filter = 0 for i = 1, 8 do - local tem = math.pow(2, i - 1) - --print("aaaaaaaaaaaaaaaaaaaaaaaa ",tem) - local btn_filter = self._view:GetChild("btn_filter" .. tem) - if btn_filter and btn_filter.selected then - filter = filter + tem - end + local tem = math.pow(2, i - 1) + ---- print("aaaaaaaaaaaaaaaaaaaaaaaa ",tem) + local btn_filter = self._view:GetChild("btn_filter" .. tem) + if btn_filter and btn_filter.selected then + filter = filter + tem + end end return filter end -- 显示原因文本 local function __getReason(data) - -- return "玩家操作" + -- return "玩家操作" local s_nick = string.utf8sub(data.m_nick, 6) if data.reason == 6 then return data.info @@ -121,14 +121,14 @@ local function __getReason(data) return string.format("[color=#FF6600]%s[/color](%s) %s", s_nick, data.mgr_id, "操作减少") -- return "每日提取" elseif data.reason == 12 then - return "推广奖励" + return "推广奖励" elseif data.reason == 13 then if data.hp < 0 then return string.format("转账给 [color=#FF6600]%s(%s)[/color]", s_nick, data.mgr_id) else return string.format("收到 [color=#FF6600]%s(%s)[/color] 转账", s_nick, data.mgr_id) - end - elseif data.reason == 14 then + end + elseif data.reason == 14 then return "提取能量包" elseif data.reason == 15 then return "" @@ -146,85 +146,85 @@ end -- 获取体力值详情数据 function M:GetData(index) - local filter = self:GetFilter() - if filter == 0 then return end - ViewUtil.ShowModalWait() + local filter = self:GetFilter() + if filter == 0 then return end + ViewUtil.ShowModalWait() local fgCtr = ControllerManager.GetController(NewGroupController) - fgCtr:FG_GetMemberHpLog(self.group_id, self.member.uid, index, 6, filter, self.begin_time, self.end_time, function(res) - if self._is_destroy then - return - end - ViewUtil.CloseModalWait() - if res.ReturnCode ~= 0 then - ViewUtil.ErrorTip(res.ReturnCode, "获取积分详情失败") - else - local data = res.Data.hp_logs - if #data == 0 then return end - -- print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") - -- pt(data) - -- pt(self.member) - for i = 1, #data do - self.hp_log[#self.hp_log + 1] = data[i] + fgCtr:FG_GetMemberHpLog(self.group_id, self.member.uid, index, 6, filter, self.begin_time, self.end_time, + function(res) + if self._is_destroy then + return end - --self:GuoLv(data) + ViewUtil.CloseModalWait() + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode, "获取积分详情失败") + else + local data = res.Data.hp_logs + if #data == 0 then return end + -- -- print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + -- pt(data) + -- pt(self.member) + for i = 1, #data do + self.hp_log[#self.hp_log + 1] = data[i] + end + --self:GuoLv(data) - self.lst_fag.numItems = #self.hp_log - end - end) + self.lst_fag.numItems = #self.hp_log + end + end) end function M:GuoLv(data) - if self.member.lev == 1 then + if self.member.lev == 1 then local m_data_other = {} local m_data_my = {} - for i=1,#data do + for i = 1, #data do if self.member.uid ~= data[i].mgr_id then - table.insert(m_data_other,data[i]) + table.insert(m_data_other, data[i]) else - table.insert(m_data_my,data[i]) + table.insert(m_data_my, data[i]) end end -- printlog("比较计算=========m_data_my>>>",#m_data_my) -- printlog("比较计算=========m_data_other>>>",#m_data_other) - - if #m_data_my>0 and #m_data_other==0 then + + if #m_data_my > 0 and #m_data_other == 0 then for i = 1, #m_data_my do - self.hp_log[#self.hp_log + 1] = m_data_my[i] + self.hp_log[#self.hp_log + 1] = m_data_my[i] end self.m_index = #data - #m_data_my + self.m_index else for i = 1, #m_data_other do - self.hp_log[#self.hp_log + 1] = m_data_other[i] + self.hp_log[#self.hp_log + 1] = m_data_other[i] end self.m_index = #data - #m_data_other + self.m_index - end + end else local m_data_other = {} local m_data_my = {} - - for i=1,#data do + + for i = 1, #data do if self.member.uid ~= data[i].mgr_id then - table.insert(m_data_other,data[i]) + table.insert(m_data_other, data[i]) end end -- printlog("比较计算11=========m_data_my>>>",#m_data_my) -- printlog("比较计算11=========m_data_other>>>",#m_data_other) - + for i = 1, #m_data_other do self.hp_log[#self.hp_log + 1] = m_data_other[i] end self.m_index = #data - #m_data_other + self.m_index end - end local function fillItem(data, obj) local num = d2ad(data.hp) obj:GetChild("tex_num").text = num >= 0 and ('+' .. num) or num - obj:GetChild("tex_time").text = os.date("%Y-%m-%d\n%H:%M",data.time) - obj:GetChild("tex_reason").text = __getReason(data) + obj:GetChild("tex_time").text = os.date("%Y-%m-%d\n%H:%M", data.time) + obj:GetChild("tex_reason").text = __getReason(data) end -- 填充体力值详情对象 @@ -236,7 +236,7 @@ function M:OnRenderItem(index, obj) obj:GetController("add").selectedIndex = num >= 0 and 1 or 0 obj:GetChild("tex_fag").text = d2ad(data.cur_hp) obj:GetChild("tex_reason").text = __getReason(data) - obj:GetChild("tex_time").text = os.date("%Y-%m-%d\n%H:%M",data.time) + obj:GetChild("tex_time").text = os.date("%Y-%m-%d\n%H:%M", data.time) local btn_head = obj:GetChild("btn_head") btn_head.icon = "ui://Common/Head0" ImageLoad.Load(self.member.portrait, btn_head._iconObject) @@ -261,7 +261,7 @@ function M:OnRenderItem(index, obj) local item = lst:AddItemFromPool() fillItem(data.detail[i], item) end - obj.height =95 * (#data.detail+1) + obj.height = 95 * (#data.detail + 1) self.lst_fag:RefreshVirtualList() self.lst_fag:ScrollToView(index) else @@ -272,7 +272,7 @@ function M:OnRenderItem(index, obj) return end ViewUtil.CloseModalWait() - if res.ReturnCode ~= 0 then + if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, "获取积分详情失败") else data.detail = res.Data.hp_logs @@ -281,7 +281,7 @@ function M:OnRenderItem(index, obj) local item = lst:AddItemFromPool() fillItem(data.detail[i], item) end - obj.height =95 * (#data.detail+1) + obj.height = 95 * (#data.detail + 1) self.lst_fag:RefreshVirtualList() self.lst_fag:ScrollToView(index) end @@ -299,7 +299,7 @@ function M:GetDailyData() return end ViewUtil.CloseModalWait() - if res.ReturnCode ~= 0 then + if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, "获取积分详情失败") else self.daily_count = res.Data.list @@ -311,9 +311,9 @@ end -- 填充日统计对象 function M:OnRenderDailyItem(index, obj) local data = self.daily_count[#self.daily_count - index] - obj:GetChild("tex_date").text = os.date("%Y-%m-%d",data.time) + obj:GetChild("tex_date").text = os.date("%Y-%m-%d", data.time) local num = d2ad(data.num) obj:GetChild("tex_num").text = num >= 0 and ('+' .. num) or num end -return M \ No newline at end of file +return M diff --git a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberOperateView.lua b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberOperateView.lua index 4a383a22..ac98501d 100644 --- a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberOperateView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMemberOperateView.lua @@ -4,7 +4,7 @@ local GroupSetPermissionView = import(".GroupSetPermissionView") local GroupBanSameTableView = import(".GroupBanSameTableView") local MngPermission = import(".MngPermission") local GroupSetTagView = import("../GroupSetTagView") -local GroupSetMemberInfoDiaoduView=import('.GroupSetMemberInfoDiaoduView') +local GroupSetMemberInfoDiaoduView = import('.GroupSetMemberInfoDiaoduView') local GroupPartnerBanPlaysView = import(".GroupPartnerBanPlaysView") -- 牌友圈成员体力值记录 @@ -12,14 +12,14 @@ local GroupMemberOperateView = {} local M = GroupMemberOperateView -function GroupMemberOperateView.new(group_id, member, callBack,callBack1) - setmetatable(M, {__index = BaseWindow}) - local self = setmetatable({}, {__index = M}) +function GroupMemberOperateView.new(group_id, member, callBack, callBack1) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) self.class = "GroupMemberOperateView" self._close_destroy = true -- self._blur_view = blur_view - --print("GroupMemberOperateView==============") - --pt(member) + ---- print("GroupMemberOperateView==============") + --pt(member) self.member = member self.group_id = group_id self.callBack = callBack @@ -30,11 +30,11 @@ end -- 管理员权限 local MngPermissionList = { - DeleteMember = 1,-- 删除成员 - AddMember = 2,--添加成员 - SetFag = 3,--设置体力值 - BanPlaying = 4,--禁止游戏 - BanSameTable = 5--禁止同桌 + DeleteMember = 1, -- 删除成员 + AddMember = 2, --添加成员 + SetFag = 3, --设置体力值 + BanPlaying = 4, --禁止游戏 + BanSameTable = 5 --禁止同桌 } local function CheckPermission(lev, permission) @@ -46,13 +46,13 @@ local function CheckPermission(lev, permission) end function M:init(url) - BaseWindow.init(self,url) + BaseWindow.init(self, url) local member = self.member - local group = DataManager.groups:get(self.group_id) - --print("DataManager.groups:get(self.group_id)") - --pt(group) - local perm_array = MngPermission.getPermData(group.permission) + local group = DataManager.groups:get(self.group_id) + ---- print("DataManager.groups:get(self.group_id)") + --pt(group) + local perm_array = MngPermission.getPermData(group.permission) local btn_close = self._view:GetChild("btn_close") btn_close.onClick:Set(function() @@ -102,10 +102,9 @@ function M:init(url) ctr_superior.selectedIndex = 0 self._view:GetChild("tex_superior_id").text = "" end - + local fgCtr = ControllerManager.GetController(NewGroupController) self._view:GetChild("btn_deploy").onClick:Set(function() - local gniv = GroupNumberInputView.new(nil, function(num) ViewUtil.ShowModalWait() local parent_id = tonumber(num) @@ -113,7 +112,7 @@ function M:init(url) if self._is_destroy then return end - if res.ReturnCode ~= 0 then + if res.ReturnCode ~= 0 then ViewUtil.CloseModalWait() ViewUtil.ErrorTip(res.ReturnCode, "找不到成员") elseif res.Data.partnerLev == 0 then @@ -125,10 +124,10 @@ function M:init(url) if (res1.ReturnCode == 0) then member.parentId = parent_id self._view:GetChild("tex_superior_id").text = parent_id - ctr_superior.selectedIndex = 1 - ViewUtil.ShowBannerOnScreenCenter("调配玩家成功") + ctr_superior.selectedIndex = 1 + ViewUtil.ShowBannerOnScreenCenter("调配玩家成功") else - ViewUtil.ErrorTip(res1.ReturnCode,"调配玩家失败") + ViewUtil.ErrorTip(res1.ReturnCode, "调配玩家失败") end end) end @@ -138,14 +137,14 @@ function M:init(url) end) local vipbtn = self._view:GetChild("btn_vip") if vipbtn ~= nil then - if (group.lev < member.lev) or (group.lev == 3 and group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id) or (group.lev < 3 and member.uid == DataManager.SelfUser.account_id ) then + if (group.lev < member.lev) or (group.lev == 3 and group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id) or (group.lev < 3 and member.uid == DataManager.SelfUser.account_id) then vipbtn.visible = true vipbtn.selected = member.isvip == 1 and true or false vipbtn.onClick:Set(function() local selected = vipbtn.selected and 1 or 0 fgCtr:FG_GroupSetVip(self.group_id, member.uid, selected, function(res1) if self._is_destroy then - return + return end ViewUtil.CloseModalWait() if res1.ReturnCode == 0 then @@ -153,7 +152,7 @@ function M:init(url) self.callBack() else vipbtn.selected = not vipbtn.selected - ViewUtil.ErrorTip(res1.ReturnCode,"设置vip失败") + ViewUtil.ErrorTip(res1.ReturnCode, "设置vip失败") end end) end) @@ -161,25 +160,25 @@ function M:init(url) vipbtn.visible = false end end - - -- 管理功能列表 + + -- 管理功能列表 local lst_mng = self._view:GetChild("lst_mng") lst_mng:RemoveChildrenToPool() -- 删除按钮 local option = group.option or 0 - if (group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id and bit:_and(option,1) == 1) or group.lev < member.lev then + if (group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id and bit:_and(option, 1) == 1) or group.lev < member.lev then local btn_del = lst_mng:AddItemFromPool() btn_del.icon = "ui://NewGroup/mng_del" btn_del.onClick:Set(function() - if not CheckPermission(group.lev, perm_array[MngPermissionList.DeleteMember]) then + if not CheckPermission(group.lev, perm_array[MngPermissionList.DeleteMember]) then return end local _curren_msg = MsgWindow.new(nil, "确定删除该成员吗?", MsgWindow.MsgMode.OkAndCancel) - _curren_msg.onOk:Add(function() + _curren_msg.onOk:Add(function() ViewUtil.ShowModalWait() fgCtr:FG_GroupRemoveMember(self.group_id, member.uid, function(res1) if self._is_destroy then - return + return end ViewUtil.CloseModalWait() if res1.ReturnCode == 0 then @@ -187,89 +186,88 @@ function M:init(url) ViewUtil.ShowBannerOnScreenCenter("已成功删除玩家") self:Destroy() else - ViewUtil.ErrorTip(res1.ReturnCode,"删除成员失败") + ViewUtil.ErrorTip(res1.ReturnCode, "删除成员失败") end end) end) _curren_msg:Show() - end) end -- 禁止游戏 - -- + -- if (group.lev < member.lev) or (group.lev == 3 and group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id) then - --if group.lev == 1 and member.lev > 1 and member.partnerLev >0 and member.uid ~= DataManager.SelfUser.account_id then + --if group.lev == 1 and member.lev > 1 and member.partnerLev >0 and member.uid ~= DataManager.SelfUser.account_id then local btn_ban = lst_mng:AddItemFromPool() local pic = member.ban == 1 and "mng_del_ban" or "mng_ban" - btn_ban.icon = "ui://NewGroup/" .. pic + btn_ban.icon = "ui://NewGroup/" .. pic btn_ban.onClick:Set(function() - if not CheckPermission(group.lev, perm_array[MngPermissionList.BanPlaying]) then + if not CheckPermission(group.lev, perm_array[MngPermissionList.BanPlaying]) then return end - + local str = member.ban == 1 and "确定恢复娱乐吗?" or "确定禁止娱乐吗?" local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel) - _curren_msg.onOk:Add(function() + _curren_msg.onOk:Add(function() ViewUtil.ShowModalWait() local val = 1 - member.ban fgCtr:FG_BanMember(self.group_id, member.uid, val, 1, function(res1) if self._is_destroy then - return + return end ViewUtil.CloseModalWait() if res1.ReturnCode == 0 then member.ban = val pic = member.ban == 1 and "mng_del_ban" or "mng_ban" - btn_ban.icon = "ui://NewGroup/" .. pic - self.callBack() + btn_ban.icon = "ui://NewGroup/" .. pic + self.callBack() else - ViewUtil.ErrorTip(res1.ReturnCode,"禁止娱乐失败!") + ViewUtil.ErrorTip(res1.ReturnCode, "禁止娱乐失败!") end end) end) _curren_msg:Show() end) end - - --print("group.type=====================") - --print(group.type) - --pt(group) + + ---- print("group.type=====================") + ---- print(group.type) + --pt(group) if member.partnerLev > 0 and group.type == 2 and member.uid ~= DataManager.SelfUser.account_id then local btn_ban = lst_mng:AddItemFromPool() local pic = member.group_ban == 1 and "mng_del_ban_group" or "mng_ban_group" - btn_ban.icon = "ui://NewGroup/" .. pic + btn_ban.icon = "ui://NewGroup/" .. pic --printlog("jefe member.partnerLev",member.partnerLev) --if member.partnerLev==1 then - btn_ban.onClick:Set(function() - -- if not CheckPermission(group.lev, perm_array[MngPermissionList.BanPlaying]) then - -- return - -- end + btn_ban.onClick:Set(function() + -- if not CheckPermission(group.lev, perm_array[MngPermissionList.BanPlaying]) then + -- return + -- end - local str = member.group_ban == 1 and "确定恢复该合伙人整组娱乐吗?" or "确定禁止该合伙人整组娱乐吗?" - local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel) - _curren_msg.onOk:Add(function() - ViewUtil.ShowModalWait() - local val = member.group_ban == 1 and 0 or 1 - fgCtr:FG_BanMember(self.group_id, member.uid, val, 2, function(res1) - if self._is_destroy then - return - end - ViewUtil.CloseModalWait() - if res1.ReturnCode == 0 then - member.group_ban = val - pic = member.group_ban == 1 and "mng_del_ban_group" or "mng_ban_group" - btn_ban.icon = "ui://NewGroup/" .. pic - self.callBack() - else - ViewUtil.ErrorTip(res1.ReturnCode,val == 1 and "禁止整组娱乐失败!" or "恢复整组娱乐失败!") - end - end) + local str = member.group_ban == 1 and "确定恢复该合伙人整组娱乐吗?" or "确定禁止该合伙人整组娱乐吗?" + local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel) + _curren_msg.onOk:Add(function() + ViewUtil.ShowModalWait() + local val = member.group_ban == 1 and 0 or 1 + fgCtr:FG_BanMember(self.group_id, member.uid, val, 2, function(res1) + if self._is_destroy then + return + end + ViewUtil.CloseModalWait() + if res1.ReturnCode == 0 then + member.group_ban = val + pic = member.group_ban == 1 and "mng_del_ban_group" or "mng_ban_group" + btn_ban.icon = "ui://NewGroup/" .. pic + self.callBack() + else + ViewUtil.ErrorTip(res1.ReturnCode, val == 1 and "禁止整组娱乐失败!" or "恢复整组娱乐失败!") + end end) - _curren_msg:Show() end) - -- end + _curren_msg:Show() + end) + -- end end -- 禁止同桌 if group.lev < 3 then @@ -277,8 +275,8 @@ function M:init(url) btn_ban_table.icon = "ui://NewGroup/mng_ban_table" btn_ban_table.onClick:Set(function() if not CheckPermission(group.lev, perm_array[MngPermissionList.BanSameTable]) then - return - end + return + end ViewUtil.ShowModalWait() fgCtr:FG_GetBanTable(self.group_id, member.uid, function(res) ViewUtil.CloseModalWait() @@ -286,37 +284,34 @@ function M:init(url) local btv = GroupBanSameTableView.new(self.blur_view, self.group_id, member.uid, res.Data) btv:Show() else - ViewUtil.ErrorTip(res.ReturnCode,"获取禁止同桌列表失败!") + ViewUtil.ErrorTip(res.ReturnCode, "获取禁止同桌列表失败!") end end) end) end - - if group.lev == 1 and member.lev > 1 and member.partnerLev >0 and member.uid ~= DataManager.SelfUser.account_id then - --if false then + + if group.lev == 1 and member.lev > 1 and member.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id then + --if false then local btn_set_mng = lst_mng:AddItemFromPool() - btn_set_mng.icon = "ui://NewGroup/zhengzu" - btn_set_mng.onClick:Set( - function() - ViewUtil.ShowModalWait() - fgCtr:FG_GetBanMemberHB(self.group_id, member.uid, function(res) - ViewUtil.CloseModalWait() - --pt(res) - if res.ReturnCode == 0 then - local diaoduView=GroupSetMemberInfoDiaoduView.new(self.group_id, member.uid) - diaoduView:SetCurrentState(res.Data.group_black+1,res.Data) - else - ViewUtil.ErrorTip(res.ReturnCode,"获取整组调度失败!") - end - - end) - - end) - - end - - + btn_set_mng.icon = "ui://NewGroup/zhengzu" + btn_set_mng.onClick:Set( + function() + ViewUtil.ShowModalWait() + fgCtr:FG_GetBanMemberHB(self.group_id, member.uid, function(res) + ViewUtil.CloseModalWait() + --pt(res) + if res.ReturnCode == 0 then + local diaoduView = GroupSetMemberInfoDiaoduView.new(self.group_id, member.uid) + diaoduView:SetCurrentState(res.Data.group_black + 1, res.Data) + else + ViewUtil.ErrorTip(res.ReturnCode, "获取整组调度失败!") + end + end) + end) + end + + -- 设置管理员 if group.lev == 1 and member.lev > 1 and member.partnerLev >= 0 then @@ -326,12 +321,12 @@ function M:init(url) btn_set_mng.onClick:Set(function() local str = member.lev == 3 and "确定设置玩家为副盟主吗?" or "确定取消玩家副盟主身份吗?" local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel) - _curren_msg.onOk:Add(function() + _curren_msg.onOk:Add(function() ViewUtil.ShowModalWait() local val = 4 - member.lev fgCtr:FG_SetManager(self.group_id, member.uid, val, function(res1) if self._is_destroy then - return + return end ViewUtil.CloseModalWait() if res1.ReturnCode == 0 then @@ -344,28 +339,28 @@ function M:init(url) end self:Destroy() else - ViewUtil.ErrorTip(res1.ReturnCode,"设置副群主失败!") + ViewUtil.ErrorTip(res1.ReturnCode, "设置副群主失败!") end end) end) _curren_msg:Show() end) end - - + + if ((group.lev < 3 and member.parentId == 0) or (group.type == 2 and member.parentId == DataManager.SelfUser.account_id)) and member.partnerLev == 0 and member.lev == 3 then - local btn_set_partner = lst_mng:AddItemFromPool() + local btn_set_partner = lst_mng:AddItemFromPool() local pic = member.partnerLev == 0 and "mng_set_partner" or "mng_del_partner" btn_set_partner.icon = "ui://NewGroup/" .. pic btn_set_partner.onClick:Set(function() local str = member.partnerLev == 0 and "确定设置玩家为合伙人吗?" or "确定取消玩家合伙人身份吗?" local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel) - _curren_msg.onOk:Add(function() + _curren_msg.onOk:Add(function() ViewUtil.ShowModalWait() local val = member.partnerLev > 0 and 2 or 1 fgCtr:FG_SetPartner(self.group_id, member.uid, val, function(res1) if self._is_destroy then - return + return end ViewUtil.CloseModalWait() if res1.ReturnCode == 0 then @@ -376,7 +371,7 @@ function M:init(url) self:Destroy() else - ViewUtil.ErrorTip(res1.ReturnCode,"设置合伙人失败失败!") + ViewUtil.ErrorTip(res1.ReturnCode, "设置合伙人失败失败!") end end) end) @@ -384,7 +379,7 @@ function M:init(url) end) end - if ((group.lev < 3 and member.parentId == 0) or (group.type == 2 and member.parentId == DataManager.SelfUser.account_id)) and member.partnerLev == 0 and member.lev == 2 then + if ((group.lev < 3 and member.parentId == 0) or (group.type == 2 and member.parentId == DataManager.SelfUser.account_id)) and member.partnerLev == 0 and member.lev == 2 then local btn_set_permission = lst_mng:AddItemFromPool() btn_set_permission.icon = "ui://NewGroup/mng_set_permission" btn_set_permission.onClick:Set(function() @@ -405,35 +400,35 @@ function M:init(url) btn_move.icon = "ui://NewGroup/mng_move" btn_move.onClick:Set(function() local gniv = GroupNumberInputView.new(nil, function(num) - local parent_id = tonumber(num) - if parent_id == member.parentId then - ViewUtil.ErrorTip(nil, "已经在该合伙人名下") - return - elseif parent_id == member.id then - ViewUtil.ErrorTip(nil, "目标的上级不能是自己") - return - elseif parent_id == DataManager.SelfUser.account_id then - self:MovePartner(parent_id, member, self._view) - return - end - ViewUtil.ShowModalWait() - local fgCtr = ControllerManager.GetController(NewGroupController) - fgCtr:FG_FindMember(self.group_id, parent_id, function(res) - if self._is_destroy then + local parent_id = tonumber(num) + if parent_id == member.parentId then + ViewUtil.ErrorTip(nil, "已经在该合伙人名下") + return + elseif parent_id == member.id then + ViewUtil.ErrorTip(nil, "目标的上级不能是自己") + return + elseif parent_id == DataManager.SelfUser.account_id then + self:MovePartner(parent_id, member, self._view) return end - if res.ReturnCode ~= 0 then - ViewUtil.CloseModalWait() - ViewUtil.ErrorTip(res.ReturnCode, "找不到成员") - elseif res.Data.partnerLev == 0 then - ViewUtil.CloseModalWait() - ViewUtil.ErrorTip(res.ReturnCode, "目标不是合伙人") - else - self:MovePartner(parent_id, member, self._view) - end - end) - end, 0, nil, "ui://NewGroup/Win_AddFriend") - gniv:Show() + ViewUtil.ShowModalWait() + local fgCtr = ControllerManager.GetController(NewGroupController) + fgCtr:FG_FindMember(self.group_id, parent_id, function(res) + if self._is_destroy then + return + end + if res.ReturnCode ~= 0 then + ViewUtil.CloseModalWait() + ViewUtil.ErrorTip(res.ReturnCode, "找不到成员") + elseif res.Data.partnerLev == 0 then + ViewUtil.CloseModalWait() + ViewUtil.ErrorTip(res.ReturnCode, "目标不是合伙人") + else + self:MovePartner(parent_id, member, self._view) + end + end) + end, 0, nil, "ui://NewGroup/Win_AddFriend") + gniv:Show() end) end @@ -454,7 +449,7 @@ function M:init(url) local btn_banplays = lst_mng:AddItemFromPool() btn_banplays.icon = "ui://NewGroup/mng_ban_plays" btn_banplays.onClick:Set(function() - local banplays = GroupPartnerBanPlaysView.new(self.group_id,member.uid) + local banplays = GroupPartnerBanPlaysView.new(self.group_id, member.uid) banplays:Show() end) end @@ -463,32 +458,32 @@ function M:init(url) local btn_qiangzhi = lst_mng:AddItemFromPool() btn_qiangzhi.icon = "ui://NewGroup/mng_qiangzhi" btn_qiangzhi.onClick:Set(function() - local msg_tip = MsgWindow.new(self._root_view,"确定全部提取吗?", MsgWindow.MsgMode.OnlyOk) - msg_tip.onOk:Add(function( ... ) - ViewUtil.ShowModalWait() + local msg_tip = MsgWindow.new(self._root_view, "确定全部提取吗?", MsgWindow.MsgMode.OnlyOk) + msg_tip.onOk:Add(function(...) + ViewUtil.ShowModalWait() fgCtr:FG_TakeHp1(self.group_id, member.uid, function(res) - ViewUtil.CloseModalWait() - if self._is_destroy then - return + ViewUtil.CloseModalWait() + if self._is_destroy then + return + end + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode, "提取失败") + else + ViewUtil.ErrorTip(res.ReturnCode, "提取成功") + self:Destroy() + if self.callBack1 then + self.callBack1() end - if res.ReturnCode ~= 0 then - ViewUtil.ErrorTip(res.ReturnCode, "提取失败") - else - ViewUtil.ErrorTip(res.ReturnCode, "提取成功") - self:Destroy() - if self.callBack1 then - self.callBack1() - end - end - end) - msg_tip:Close() + end end) + msg_tip:Close() + end) msg_tip:Show() end) end end -function M:MovePartner(parent_id, member, obj) +function M:MovePartner(parent_id, member, obj) local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_MovePartner(self.group_id, member.uid, parent_id, function(res1) ViewUtil.CloseModalWait() @@ -496,13 +491,12 @@ function M:MovePartner(parent_id, member, obj) member.parentId = parent_id member.partnerLev = res1.Data.partnerLev obj:GetChild("tex_superior_id").text = parent_id - obj:GetController("show_superior").selectedIndex = 1 - ViewUtil.ShowBannerOnScreenCenter("转移成功") + obj:GetController("show_superior").selectedIndex = 1 + ViewUtil.ShowBannerOnScreenCenter("转移成功") else - ViewUtil.ErrorTip(res1.ReturnCode,"转移失败") + ViewUtil.ErrorTip(res1.ReturnCode, "转移失败") end end) end - -return M \ No newline at end of file +return M diff --git a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngGameListView.lua b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngGameListView.lua index a4c1a605..8883c8b5 100644 --- a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngGameListView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngGameListView.lua @@ -65,7 +65,7 @@ function M:OnRenderItem(index, obj) local hpStr local hpData = json.decode(play.hpData) if play.hpOnOff == 1 then - -- print(vardump(play)) + -- -- print(vardump(play)) local str_reward_type = play.rewardType == 1 and "赢家返点" or (play.rewardType == 2 and "人头返点") local str_reward_val = play.rewardValueType == 1 and "百分比返点" or "固定值返点" local str_hp_type = hpData.type == 1 and "固定抽水" or "浮动抽水" diff --git a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView.lua b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView.lua index d92c4ee6..b289fdc3 100644 --- a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView.lua +++ b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView.lua @@ -4,7 +4,7 @@ local GroupMemberFagLogView = import('.GroupMemberFagLogView') local GroupSetPermissionView = import('.GroupSetPermissionView') local GroupBanSameTableView = import('.GroupBanSameTableView') local GroupMemberOperateView = import('.GroupMemberOperateView') -local GroupAddMemberInfoView=import('.GroupAddMemberInfoView') +local GroupAddMemberInfoView = import('.GroupAddMemberInfoView') local MngPermission = import('.MngPermission') @@ -62,15 +62,15 @@ function M:FillView() end self.lst_member.scrollPane.onPullUpRelease:Set( function() - --print("aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbb ",self.lst_member.numItems) + ---- print("aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbb ",self.lst_member.numItems) self:GetMemberData(self.lst_member.numItems) end ) - - --local n50=self._view:GetChild('n50') - --print(n50) - --n50.displayObject.gameObject.transform.localPosition.x=214 - --print(n50.displayObject.gameObject.transform.localPosition.x) + + --local n50=self._view:GetChild('n50') + ---- print(n50) + --n50.displayObject.gameObject.transform.localPosition.x=214 + ---- print(n50.displayObject.gameObject.transform.localPosition.x) -- 搜索玩家 local ctr_search = self._view:GetController('search') self._view:GetChild('btn_search').onClick:Set( @@ -103,8 +103,8 @@ function M:FillView() item_result:RemoveChildrenToPool() for j = 1, #res.Data.members do - local tem = item_result:AddItemFromPool() - self:FillItem(tem, res.Data.members[j], true) + local tem = item_result:AddItemFromPool() + self:FillItem(tem, res.Data.members[j], true) end end end, @@ -147,11 +147,11 @@ function M:FillView() self.group_id, tonumber(self._texnum_str), function(response) - printlog("响应获取添加玩家==》》》") - pt(response) + printlog("响应获取添加玩家==》》》") + pt(response) ViewUtil.CloseModalWait() if (response.ReturnCode and response.ReturnCode == 0) then - GroupAddMemberInfoView.new(self.group_id,tonumber(self._texnum_str)):SetAddMember(response.Data) + GroupAddMemberInfoView.new(self.group_id, tonumber(self._texnum_str)):SetAddMember(response.Data) self:ClearNumTex() --ViewUtil.ShowBannerOnScreenCenter('添加成功!', 1) else @@ -174,9 +174,6 @@ function M:FillView() self:initData() end ) - - - end -- 快速访问 @@ -187,8 +184,8 @@ end -- 获取成员数据 function M:GetMemberData(index) - --print("11111111111111111111") - --print(debug.traceback()) + ---- print("11111111111111111111") + ---- print(debug.traceback()) local group = DataManager.groups:get(self.group_id) if index == 0 then group:clearMember() @@ -222,32 +219,32 @@ end local function __change_fag(gid, pid, is_add, cur_hp, callback) local gniv = GroupNumberInputView.new( - nil, - function(num) - num = ad2d((is_add and num or -num)) - ViewUtil.ShowModalWait() - local fgCtr = ControllerManager.GetController(NewGroupController) - fgCtr:FG_ChangeFag( - gid, - pid, - num, - function(res1) - ViewUtil.CloseModalWait() - -- if gniv._is_destroy then - -- return - -- end - if (res1.ReturnCode == 0) then - callback(res1.Data) - else - ViewUtil.ErrorTip(res1.ReturnCode, '更改积分失败!') + nil, + function(num) + num = ad2d((is_add and num or -num)) + ViewUtil.ShowModalWait() + local fgCtr = ControllerManager.GetController(NewGroupController) + fgCtr:FG_ChangeFag( + gid, + pid, + num, + function(res1) + ViewUtil.CloseModalWait() + -- if gniv._is_destroy then + -- return + -- end + if (res1.ReturnCode == 0) then + callback(res1.Data) + else + ViewUtil.ErrorTip(res1.ReturnCode, '更改积分失败!') + end end - end - ) - -- item:GetChild("tex_fag").text = (self_user or show_fag) and num or show_fag_str - end, - is_add and 1 or 2, - cur_hp and d2ad(cur_hp) or nil - ) + ) + -- item:GetChild("tex_fag").text = (self_user or show_fag) and num or show_fag_str + end, + is_add and 1 or 2, + cur_hp and d2ad(cur_hp) or nil + ) gniv:Show() end @@ -284,16 +281,16 @@ function M:FillItem(obj, member, refresh) obj:GetChild('tex_last_login').text = '加入时间\n' .. os.date('%Y/%m/%d', member.join_time) end end - - - --上级 - obj:GetChild('tex_shangjiName').text=member.parentId_nick or "" - if member.parentId==0 then - obj:GetChild('tex_shangjiID').text="" - else - obj:GetChild('tex_shangjiID').text=member.parentId - end - + + + --上级 + obj:GetChild('tex_shangjiName').text = member.parentId_nick or "" + if member.parentId == 0 then + obj:GetChild('tex_shangjiID').text = "" + else + obj:GetChild('tex_shangjiID').text = member.parentId + end + local perm_array = MngPermission.getPermData(group.permission) -- 体力值操作按钮事件 @@ -378,22 +375,22 @@ function M:FillItem(obj, member, refresh) function() local mflv = GroupMemberOperateView.new( - self.group_id, - member, - function(delete) - if delete ~= nil and delete == true then - local group = DataManager.groups:get(self.group_id) - self.member_data = group.members - self.lst_member.numItems = #self.member_data - self._view:GetController('search').selectedIndex = 0 - else - self.lst_member.numItems = self.lst_member.numItems - if refresh then - self:FillItem(obj, member) + self.group_id, + member, + function(delete) + if delete ~= nil and delete == true then + local group = DataManager.groups:get(self.group_id) + self.member_data = group.members + self.lst_member.numItems = #self.member_data + self._view:GetController('search').selectedIndex = 0 + else + self.lst_member.numItems = self.lst_member.numItems + if refresh then + self:FillItem(obj, member) + end end end - end - ) + ) mflv:Show() end ) @@ -428,8 +425,8 @@ function M:FillItem(obj, member, refresh) item_result:RemoveChildrenToPool() for j = 1, #res.Data.members do - local tem = item_result:AddItemFromPool() - self:FillItem(tem, res.Data.members[j], true) + local tem = item_result:AddItemFromPool() + self:FillItem(tem, res.Data.members[j], true) end end end, @@ -442,7 +439,7 @@ end function M:OnRenderItem(index, obj) local member = self.member_data[index + 1] - + if member then self:FillItem(obj, member) end diff --git a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView1.lua b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView1.lua index 1474a2a8..7317b859 100644 --- a/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView1.lua +++ b/lua_probject/base_project/Game/View/NewGroup/MngView/GroupMngMemberListView1.lua @@ -4,7 +4,7 @@ local GroupMemberFagLogView = import('.GroupMemberFagLogView') local GroupSetPermissionView = import('.GroupSetPermissionView') local GroupBanSameTableView = import('.GroupBanSameTableView') local GroupMemberOperateView = import('.GroupMemberOperateView') -local GroupAddMemberInfoView=import('.GroupAddMemberInfoView') +local GroupAddMemberInfoView = import('.GroupAddMemberInfoView') local GroupStatMember = import('.GroupStatMember') local GroupMngFagPackView = import('../GroupMngFagPackView') @@ -64,16 +64,15 @@ function M:FillView() local rtype = self._view:GetChild("n132") rtype.visible = false - rtype.onChanged:Set(function () + rtype.onChanged:Set(function() if tostring(self.online) == rtype.value then return end self.online = tonumber(rtype.value) self:GetMemberData(0) --printlog("aaaaaaaa222222222222222222222222222222") - end) - + -- 初始化成员列表 self.lst_member = self._view:GetChild('lst_member') self.lst_member:SetVirtual() @@ -86,11 +85,11 @@ function M:FillView() self:GetMemberData(self.lst_member.numItems) end ) - - --local n50=self._view:GetChild('n50') - --print(n50) - --n50.displayObject.gameObject.transform.localPosition.x=214 - --print(n50.displayObject.gameObject.transform.localPosition.x) + + --local n50=self._view:GetChild('n50') + ---- print(n50) + --n50.displayObject.gameObject.transform.localPosition.x=214 + ---- print(n50.displayObject.gameObject.transform.localPosition.x) -- 搜索玩家 local ctr_search = self._view:GetController('search') self._view:GetChild('btn_search').onClick:Set( @@ -123,8 +122,8 @@ function M:FillView() item_result:RemoveChildrenToPool() for j = 1, #res.Data.members do - local tem = item_result:AddItemFromPool() - self:FillItem(tem, res.Data.members[j], true) + local tem = item_result:AddItemFromPool() + self:FillItem(tem, res.Data.members[j], true) end end end, @@ -167,11 +166,11 @@ function M:FillView() self.group_id, tonumber(self._texnum_str), function(response) - printlog("响应获取添加玩家==》》》") - pt(response) + printlog("响应获取添加玩家==》》》") + pt(response) ViewUtil.CloseModalWait() if (response.ReturnCode and response.ReturnCode == 0) then - GroupAddMemberInfoView.new(self.group_id,tonumber(self._texnum_str)):SetAddMember(response.Data) + GroupAddMemberInfoView.new(self.group_id, tonumber(self._texnum_str)):SetAddMember(response.Data) self:ClearNumTex() --ViewUtil.ShowBannerOnScreenCenter('添加成功!', 1) else @@ -195,18 +194,15 @@ function M:FillView() --ctr_page.selectedIndex = 1 --self.stype = 2 end - - + + --self._view:GetChild("n50").selected = true ctr_page.onChanged:Set( function() - self.stype = ctr_page.selectedIndex + 1 self:initData() end ) - - end -- 快速访问 @@ -217,8 +213,8 @@ end -- 获取成员数据 function M:GetMemberData(index) - --print("11111111111111111111") - --print(debug.traceback()) + ---- print("11111111111111111111") + ---- print(debug.traceback()) -- local iClear = false -- local rtype = self._view:GetChild("n132").value -- if tostring(self.online) ~= rtype then @@ -258,32 +254,32 @@ end local function __change_fag(gid, pid, is_add, cur_hp, callback) local gniv = GroupNumberInputView.new( - nil, - function(num) - num = ad2d((is_add and num or -num)) - ViewUtil.ShowModalWait() - local fgCtr = ControllerManager.GetController(NewGroupController) - fgCtr:FG_ChangeFag( - gid, - pid, - num, - function(res1) - ViewUtil.CloseModalWait() - -- if gniv._is_destroy then - -- return - -- end - if (res1.ReturnCode == 0) then - callback(res1.Data) - else - ViewUtil.ErrorTip(res1.ReturnCode, '更改积分失败!') + nil, + function(num) + num = ad2d((is_add and num or -num)) + ViewUtil.ShowModalWait() + local fgCtr = ControllerManager.GetController(NewGroupController) + fgCtr:FG_ChangeFag( + gid, + pid, + num, + function(res1) + ViewUtil.CloseModalWait() + -- if gniv._is_destroy then + -- return + -- end + if (res1.ReturnCode == 0) then + callback(res1.Data) + else + ViewUtil.ErrorTip(res1.ReturnCode, '更改积分失败!') + end end - end - ) - -- item:GetChild("tex_fag").text = (self_user or show_fag) and num or show_fag_str - end, - is_add and 1 or 2, - cur_hp and d2ad(cur_hp) or nil - ) + ) + -- item:GetChild("tex_fag").text = (self_user or show_fag) and num or show_fag_str + end, + is_add and 1 or 2, + cur_hp and d2ad(cur_hp) or nil + ) gniv:Show() end @@ -296,7 +292,7 @@ function M:FillItem(obj, member, refresh) -- obj.data = member.id -- 显示玩家标签,合伙人、管理员 local ctr_type = obj:GetController('type') - + if member.lev < 3 then ctr_type.selectedIndex = member.lev elseif member.partnerLev ~= 0 then @@ -313,36 +309,36 @@ function M:FillItem(obj, member, refresh) --obj:GetChild("tex_cost_count").text = d2ad(member.last_hp_cost) --if member.online == 1 then - -- obj:GetChild('tex_last_login').text = '在线' - -- else - if member.last_time ~= 0 then - -- local now_time = os.date("*t",now) - -- local today = os.time({year=now_time.year, month=now_time.month, day=now_time.day, hour=0,min=0,sec=0}) - -- local cha = math.ceil((today - member.last_time) / (24 * 60 *60)) - -- if (cha > 0) then - -- obj:GetChild('tex_last_login').text = cha.."天前" --'最近登录\n' .. os.date('%Y/%m/%d', member.last_time) - -- else - -- obj:GetChild('tex_last_login').text = os.date('%Y/%m/%d', member.last_time) - -- end - --print("11111aaaaaaaaaaaaaaaaaaaa ",os.date('%Y/%m/%d', member.last_time)) - obj:GetChild('tex_last_login').text = "最近登录:"..os.date('%Y/%m/%d', member.last_time) - else - obj:GetChild('tex_last_login').text = '加入时间\n' .. os.date('%Y/%m/%d', member.join_time) - end - -- end - - + -- obj:GetChild('tex_last_login').text = '在线' + -- else + if member.last_time ~= 0 then + -- local now_time = os.date("*t",now) + -- local today = os.time({year=now_time.year, month=now_time.month, day=now_time.day, hour=0,min=0,sec=0}) + -- local cha = math.ceil((today - member.last_time) / (24 * 60 *60)) + -- if (cha > 0) then + -- obj:GetChild('tex_last_login').text = cha.."天前" --'最近登录\n' .. os.date('%Y/%m/%d', member.last_time) + -- else + -- obj:GetChild('tex_last_login').text = os.date('%Y/%m/%d', member.last_time) + -- end + ---- print("11111aaaaaaaaaaaaaaaaaaaa ",os.date('%Y/%m/%d', member.last_time)) + obj:GetChild('tex_last_login').text = "最近登录:" .. os.date('%Y/%m/%d', member.last_time) + else + obj:GetChild('tex_last_login').text = '加入时间\n' .. os.date('%Y/%m/%d', member.join_time) + end + -- end + + obj:GetChild('tex_zongchangci').text = member.total_round obj:GetChild('tex_ruhui').text = os.date('%Y/%m/%d %H:%M:%S', member.join_time) - - --上级 - obj:GetChild('tex_shangjiName').text=member.parentId_nick or "" - if member.parentId==0 then - obj:GetChild('tex_shangjiID').text="" - else - obj:GetChild('tex_shangjiID').text=member.parentId - end - + + --上级 + obj:GetChild('tex_shangjiName').text = member.parentId_nick or "" + if member.parentId == 0 then + obj:GetChild('tex_shangjiID').text = "" + else + obj:GetChild('tex_shangjiID').text = member.parentId + end + local perm_array = MngPermission.getPermData(group.permission) -- 体力值操作按钮事件 @@ -427,40 +423,41 @@ function M:FillItem(obj, member, refresh) function() local mflv = GroupMemberOperateView.new( - self.group_id, - member, - function(delete) - if delete ~= nil and delete == true then - local group = DataManager.groups:get(self.group_id) - self.member_data = group.members - self.lst_member.numItems = #self.member_data - self._view:GetController('search').selectedIndex = 0 - else - self.lst_member.numItems = self.lst_member.numItems - if refresh then - self:FillItem(obj, member) + self.group_id, + member, + function(delete) + if delete ~= nil and delete == true then + local group = DataManager.groups:get(self.group_id) + self.member_data = group.members + self.lst_member.numItems = #self.member_data + self._view:GetController('search').selectedIndex = 0 + else + self.lst_member.numItems = self.lst_member.numItems + if refresh then + self:FillItem(obj, member) + end end + end, + function() + self:GetMemberData(0) end - end, - function() - self:GetMemberData(0) - end - ) + ) mflv:Show() end ) local btnBxx = obj:GetChild('btn_bxx') - btnBxx.visible = (not (member.lev == 3 and member.partnerLev == 0)) and not (DataManager.SelfUser.account_id == member.uid) + btnBxx.visible = (not (member.lev == 3 and member.partnerLev == 0)) and + not (DataManager.SelfUser.account_id == member.uid) --btnBxx.visible = not (DataManager.SelfUser.account_id == member.uid) obj:GetChild('btn_bxx').onClick:Set( function() - local ctrNum=1 + local ctrNum = 1 -- if not (member.lev == 3 and member.partnerLev == 0) then -- ctrNum = 2 -- end - ctrNum=2 - local gmv = GroupMngFagPackView.new(self.curGroup.id, self._root_view,ctrNum,member.uid) + ctrNum = 2 + local gmv = GroupMngFagPackView.new(self.curGroup.id, self._root_view, ctrNum, member.uid) gmv:SetCallback( function() btnBxx.selected = false @@ -471,7 +468,7 @@ function M:FillItem(obj, member, refresh) ) local superBtn = obj:GetChild('super_btn') - superBtn.visible = group.lev == 1 + superBtn.visible = group.lev == 1 obj:GetChild("super_btn").onClick:Set( function() ViewUtil.ShowModalWait(nil) @@ -502,8 +499,8 @@ function M:FillItem(obj, member, refresh) item_result:RemoveChildrenToPool() for j = 1, #res.Data.members do - local tem = item_result:AddItemFromPool() - self:FillItem(tem, res.Data.members[j], true) + local tem = item_result:AddItemFromPool() + self:FillItem(tem, res.Data.members[j], true) end end end, diff --git a/lua_probject/base_project/Game/View/PlayerInfoView.lua b/lua_probject/base_project/Game/View/PlayerInfoView.lua index 3cf632e9..dbed8a23 100644 --- a/lua_probject/base_project/Game/View/PlayerInfoView.lua +++ b/lua_probject/base_project/Game/View/PlayerInfoView.lua @@ -22,13 +22,13 @@ local M = PlayerInfoView function M.new(view, main_view, isHideIpAdds) local self = {} - setmetatable(self, {__index = PlayerInfoView}) + setmetatable(self, { __index = PlayerInfoView }) self._view = view self._main_view = main_view self._isHideIpAdds = isHideIpAdds - self.isShowTGTimer=false - self.currentTime=0 - self.totalTime=0 + self.isShowTGTimer = false + self.currentTime = 0 + self.totalTime = 0 --self.isShow = fasle self:init() return self @@ -41,36 +41,36 @@ function M:init() self._tex_player_name = player_name_score:GetChild('tex_player_name') self._tex_player_id = player_name_score:GetChild('tex_player_id') self._tex_score = player_name_score:GetChild('tex_score') - self._tex_score.visible=true - - self._tex_score1 = self._view:GetChild("info"):GetChild("tex_score1") - if self._tex_score1 then - self._tex_score1.visible=true - end + self._tex_score.visible = true + + self._tex_score1 = self._view:GetChild("info"):GetChild("tex_score1") + if self._tex_score1 then + self._tex_score1.visible = true + end self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2") - if self._tex_score2 then - self._tex_score2.visible=true - end - - self._tex_n4 = self._view:GetChild("info"):GetChild("n4") - if self._tex_n4 then - self._tex_n4.visible=true - end + if self._tex_score2 then + self._tex_score2.visible = true + end + + self._tex_n4 = self._view:GetChild("info"):GetChild("n4") + if self._tex_n4 then + self._tex_n4.visible = true + end self._tex_n5 = self._view:GetChild("info"):GetChild("n5") - if self._tex_n5 then - self._tex_n5.visible=true - end - - self.n3Bg=self._view:GetChild("info"):GetChild("n3") - if self.n3Bg then - --self.n3Bg:SetSize(138,55) - end - self.zhanjitext=self._view:GetChild("text_jifen") - if self.zhanjitext then - self.zhanjitext.text=0 - end - - + if self._tex_n5 then + self._tex_n5.visible = true + end + + self.n3Bg = self._view:GetChild("info"):GetChild("n3") + if self.n3Bg then + --self.n3Bg:SetSize(138,55) + end + self.zhanjitext = self._view:GetChild("text_jifen") + if self.zhanjitext then + self.zhanjitext.text = 0 + end + + self._biaoqing = view:GetChild('face') self._chat = view:GetChild('chat') @@ -82,69 +82,64 @@ function M:init() self._ctr_room_owner = view:GetController('room_owner') self._ctr_mask_voice = view:GetController('mask_voice') self._ctr_dismiss_room = view:GetController('dismiss_room') - - self.PlayerTGTips=view:GetChild('tuoguanTips') - if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then - self.PlayerTGTips.displayObject.gameObject:SetActive(false) - end - + + self.PlayerTGTips = view:GetChild('tuoguanTips') + if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then + self.PlayerTGTips.displayObject.gameObject:SetActive(false) + end end - -function M:IsShowTGTips(isShow,time) +function M:IsShowTGTips(isShow, time) --printlog("isShowisShowisShow==== ",isShow," time ",time) - if time==nil then time=0 end - - self.isShowTGTimer = isShow - if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then - self.PlayerTGTips.displayObject.gameObject:SetActive(isShow) - end - self.currentTime=0 - if isShow then - if self.PlayerTGTips then - self.PlayerTGTips.text="开启托管剩余时间"..time.."s" - end - self.totalTime=time - --UpdateBeat:Remove(self.OnUpdate,self) - --UpdateBeat:Add(self.OnUpdate,self) - -- printlog("aaaaaaaaa111111111111111111111111111111") - --TimerManager.RemoveTimer(self.OnUpdate) - TimerManager.AddTimer(self.OnUpdate,self) - --printlog(self) - else - -- printlog("移除IsShowTGTips",self.isShow) - --UpdateBeat:Remove(self.OnUpdate,self) - TimerManager.RemoveTimer(self.OnUpdate,self) - end - -end + if time == nil then time = 0 end + self.isShowTGTimer = isShow + if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then + self.PlayerTGTips.displayObject.gameObject:SetActive(isShow) + end + self.currentTime = 0 + if isShow then + if self.PlayerTGTips then + self.PlayerTGTips.text = "开启托管剩余时间" .. time .. "s" + end + self.totalTime = time + --UpdateBeat:Remove(self.OnUpdate,self) + --UpdateBeat:Add(self.OnUpdate,self) + -- printlog("aaaaaaaaa111111111111111111111111111111") + --TimerManager.RemoveTimer(self.OnUpdate) + TimerManager.AddTimer(self.OnUpdate, self) + --printlog(self) + else + -- printlog("移除IsShowTGTips",self.isShow) + --UpdateBeat:Remove(self.OnUpdate,self) + TimerManager.RemoveTimer(self.OnUpdate, self) + end +end function M:OnUpdate() - --printlog("OnUpdate=====================") - if self.isShowTGTimer then - self.currentTime=self.currentTime+Time.deltaTime - if self.currentTime>=1 then - self.currentTime=0 - self.totalTime=self.totalTime-1 - --printlog("当前计时器===>>>",self.totalTime) - if self.PlayerTGTips then - self.PlayerTGTips.text="开启托管剩余时间"..self.totalTime.."s" - end - - if self.totalTime<=0 then - self.isShowTGTimer=false - if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then - self.PlayerTGTips.displayObject.gameObject:SetActive(false) - end - end - end + --printlog("OnUpdate=====================") + if self.isShowTGTimer then + self.currentTime = self.currentTime + Time.deltaTime + if self.currentTime >= 1 then + self.currentTime = 0 + self.totalTime = self.totalTime - 1 + --printlog("当前计时器===>>>",self.totalTime) + if self.PlayerTGTips then + self.PlayerTGTips.text = "开启托管剩余时间" .. self.totalTime .. "s" + end - if self.muShiPlayerUpdate then - self:muShiPlayerUpdate() - end - end - + if self.totalTime <= 0 then + self.isShowTGTimer = false + if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then + self.PlayerTGTips.displayObject.gameObject:SetActive(false) + end + end + end + + if self.muShiPlayerUpdate then + self:muShiPlayerUpdate() + end + end end function M:FillData(player) @@ -164,7 +159,7 @@ function M:FillData(player) --local headView = HeadView.new(self._main_view._root_view, player.self_user, self._isHideIpAdds) --headView:Show() end - ) + ) else local ctr = self._btn_head:GetController("hidden") if ctr then @@ -172,13 +167,13 @@ function M:FillData(player) end end - if isHidden - --and player.self_user.account_id ~= room.self_player.self_user.account_id + if isHidden + --and player.self_user.account_id ~= room.self_player.self_user.account_id then if player.orgSeat and player.orgSeat > 0 then - self._tex_player_name.text = "玩家"..player.orgSeat + self._tex_player_name.text = "玩家" .. player.orgSeat else - self._tex_player_name.text = "玩家"..player.seat + self._tex_player_name.text = "玩家" .. player.seat player.orgSeat = membe_clone(player.seat) end if self._tex_player_id then @@ -187,7 +182,7 @@ function M:FillData(player) else self._tex_player_name.text = player.self_user.nick_name if self._tex_player_id then - self._tex_player_id.text = "ID:".. player.self_user.account_id + self._tex_player_id.text = "ID:" .. player.self_user.account_id end end self._ctr_room_owner.selectedIndex = room.owner_id == player.self_user.account_id and 1 or 0 @@ -208,12 +203,12 @@ function M:UpdateScore(score) local room = DataManager.CurrenRoom if room:checkHpNonnegative() then if self._player.cur_hp then - -- print(self._player.total_hp) + -- -- print(self._player.total_hp) -- if self._player.total_hp then -- score = d2ad(self._player.total_hp).."/"..d2ad(self._player.cur_hp) -- else score = d2ad(self._player.cur_hp) - -- end + -- end end end end @@ -339,9 +334,11 @@ function M:MarkTuoguan() local com_tuoguan = UIPackage.CreateObjectFromURL('ui://Common/com_tuoguan') self:AddMarkToHead(com_tuoguan, 'mark_tuoguan') end + function M:UnmarkTuoguan() self:RemoveMarkFromHead('mark_tuoguan') end + -- 动态的往头像上加载组件 function M:AddMarkToHead(com, key) if key then @@ -354,6 +351,7 @@ function M:AddMarkToHead(com, key) com.touchable = false com.xy = self:GetHeadCenter() end + -- 动态移除组件 function M:RemoveMarkFromHead(key) if self[key] then @@ -363,11 +361,10 @@ function M:RemoveMarkFromHead(key) end function M:Destroy() - self.isShowTGTimer=false - TimerManager.RemoveTimer(self.OnUpdate,self) - self.OnUpdate=nil - self.muShiPlayerUpdate=nil + self.isShowTGTimer = false + TimerManager.RemoveTimer(self.OnUpdate, self) + self.OnUpdate = nil + self.muShiPlayerUpdate = nil end - return M diff --git a/lua_probject/base_project/Game/View/PlayerInfoView_copy.lua b/lua_probject/base_project/Game/View/PlayerInfoView_copy.lua index 172417cc..d5929263 100644 --- a/lua_probject/base_project/Game/View/PlayerInfoView_copy.lua +++ b/lua_probject/base_project/Game/View/PlayerInfoView_copy.lua @@ -128,7 +128,7 @@ function M:FillData(player) end end - print("============================playinfoview") + -- print("============================playinfoview") pt(player) if isHidden diff --git a/lua_probject/base_project/Game/View/ViewUtil.lua b/lua_probject/base_project/Game/View/ViewUtil.lua index d5c71650..c191b345 100644 --- a/lua_probject/base_project/Game/View/ViewUtil.lua +++ b/lua_probject/base_project/Game/View/ViewUtil.lua @@ -129,8 +129,8 @@ end function ViewUtil.HandCardSort2(a, b) a = tonumber(string.sub(a, 2)) b = tonumber(string.sub(b, 2)) - --print(a) - --print(b) + ---- print(a) + ---- print(b) return a < b end @@ -242,7 +242,7 @@ function get_gps(callback) end) end) if not s then - --print("Error" .. e) + ---- print("Error" .. e) end elseif Application.platform == RuntimePlatform.WindowsPlayer or Application.platform == RuntimePlatform.WindowsEditor then -- DataManager.SelfUser.location = Location.new(string.format("%s,%s", math.random(10,20), math.random(10,20))) diff --git a/lua_probject/base_project/Game/ViewManager.lua b/lua_probject/base_project/Game/ViewManager.lua index d2f3a499..3ae02610 100644 --- a/lua_probject/base_project/Game/ViewManager.lua +++ b/lua_probject/base_project/Game/ViewManager.lua @@ -53,7 +53,7 @@ local function __NetTip(txt_msg) end local function __OnGameConnectAction(state) - --print("state:"..state) + ---- print("state:"..state) NetResetConnectWindow.CloseNetReset() if state == SocketCode.Connect then ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) @@ -150,14 +150,14 @@ function ViewManager.ChangeView(id, game_id, callback) end function ViewManager.OnApplicationPause() - -- print("game pause") + -- -- print("game pause") if (_currenView ~= nil) then _currenView:OnApplicationPause() end end function ViewManager.OnApplicationActive() - -- print("game active") + -- -- print("game active") if (_currenView ~= nil) then _currenView:OnApplicationActive() end diff --git a/lua_probject/base_project/LuaDebug.lua b/lua_probject/base_project/LuaDebug.lua index f7481d24..f75f210a 100644 --- a/lua_probject/base_project/LuaDebug.lua +++ b/lua_probject/base_project/LuaDebug.lua @@ -1,7 +1,7 @@ -local debugger_reLoadFile =nil -xpcall(function() +local debugger_reLoadFile = nil +xpcall(function() debugger_reLoadFile = require("luaideReLoadFile") -end,function() +end, function() debugger_reLoadFile = function() print("未实现代码重载") end end) local debugger_stackInfo = nil @@ -21,27 +21,27 @@ local setfenv = setfenv if (not setfenv) then setfenv = function(fn, env) - local i = 1 - while true do - local name = debug.getupvalue(fn, i) - if name == "_ENV" then - debug.upvaluejoin( - fn, - i, - (function() - return env - end), - 1 - ) - break - elseif not name then - break - end + local i = 1 + while true do + local name = debug.getupvalue(fn, i) + if name == "_ENV" then + debug.upvaluejoin( + fn, + i, + (function() + return env + end), + 1 + ) + break + elseif not name then + break + end - i = i + 1 + i = i + 1 + end + return fn end - return fn - end end local ZZBase64 = {} local LuaDebugTool_ = nil @@ -154,50 +154,50 @@ local function createSocket() sinkt["close-when-done"] = function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if not chunk then - sock:close() - return 1 - else - return sock:send(chunk) + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - end - } - ) - end + }, + { + __call = function(self, chunk, err) + if not chunk then + sock:close() + return 1 + else + return sock:send(chunk) + end + end + } + ) + end sinkt["keep-open"] = function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if chunk then - return sock:send(chunk) - else - return 1 + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - end - } - ) - end + }, + { + __call = function(self, chunk, err) + if chunk then + return sock:send(chunk) + else + return 1 + end + end + } + ) + end sinkt["default"] = sinkt["keep-open"] @@ -205,63 +205,63 @@ local function createSocket() sourcet["by-length"] = function(sock, length) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if length <= 0 then - return nil + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local size = math.min(socket.BLOCKSIZE, length) - local chunk, err = sock:receive(size) - if err then - return nil, err + }, + { + __call = function() + if length <= 0 then + return nil + end + local size = math.min(socket.BLOCKSIZE, length) + local chunk, err = sock:receive(size) + if err then + return nil, err + end + length = length - string.len(chunk) + return chunk end - length = length - string.len(chunk) - return chunk - end - } - ) - end + } + ) + end sourcet["until-closed"] = function(sock) - local done - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if done then - return nil + local done + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local chunk, err, partial = sock:receive(socket.BLOCKSIZE) - if not err then - return chunk - elseif err == "closed" then - sock:close() - done = 1 - return partial - else - return nil, err + }, + { + __call = function() + if done then + return nil + end + local chunk, err, partial = sock:receive(socket.BLOCKSIZE) + if not err then + return chunk + elseif err == "closed" then + sock:close() + done = 1 + return partial + else + return nil, err + end end - end - } - ) - end + } + ) + end sourcet["default"] = sourcet["until-closed"] @@ -278,7 +278,7 @@ local function createJson() ----------------------------------------------------------------------------- -- Module declaration ----------------------------------------------------------------------------- - local json = {} -- Public namespace + local json = {} -- Public namespace local json_private = {} -- Private namespace -- Public constants @@ -392,6 +392,7 @@ local function createJson() function json.null() return json.null -- so json.null() will also return null ;-) end + ----------------------------------------------------------------------------- -- Internal, PRIVATE functions. -- Following a Python-like convention, I have prefixed all these 'PRIVATE' @@ -449,8 +450,8 @@ local function createJson() -- @return object, int The object (true, false or nil) and the position at which the next character should be -- scanned. function decode_scanConstant(s, startPos) - local consts = {["true"] = true, ["false"] = false, ["null"] = nil} - local constNames = {"true", "false", "null"} + local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } + local constNames = { "true", "false", "null" } for i, k in pairs(constNames) do if string.sub(s, startPos, startPos + string.len(k) - 1) == k then @@ -599,7 +600,7 @@ local function createJson() assert( string.find(s, startChar, j + 1), "String decoding failed: missing closing " .. - startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" + startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" ) return table.concat(t, ""), j + 2 -- END SoniEx2 @@ -675,13 +676,13 @@ local function createJson() if v ~= (t.n or #t) then return false end -- False if n does not hold the number of elements - else -- Else of (k=='n') + else -- Else of (k=='n') if isEncodable(v) then return false end end -- End of (k~='n') - end -- End of k,v not an indexed pair - end -- End of loop across all pairs + end -- End of k,v not an indexed pair + end -- End of loop across all pairs return true, maxIndex end @@ -704,7 +705,7 @@ local breakInfoSocket = nil local json = createJson() local LuaDebugger = { fileMaps = {}, - Run = true, --表示正常运行只检测断点 + Run = true, --表示正常运行只检测断点 StepIn = false, StepInLevel = 0, StepNext = false, @@ -776,17 +777,17 @@ function print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} + arg = { "nil" } end for k, v in pairs(arg) do str = str .. tostring(v) .. "\t" end local sendMsg = { event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 1} + data = { msg = ZZBase64.encode(str), type = 1 } } local sendStr = json.encode(sendMsg) debug_server:send(sendStr .. "__debugger_k0204__") @@ -800,46 +801,48 @@ function luaIdePrintWarn(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} + arg = { "nil" } end for k, v in pairs(arg) do str = str .. tostring(v) .. "\t" end local sendMsg = { event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 2} + data = { msg = ZZBase64.encode(str), type = 2 } } local sendStr = json.encode(sendMsg) debug_server:send(sendStr .. "__debugger_k0204__") end end end + function luaIdePrintErr(...) if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then debugger_print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} + arg = { "nil" } end for k, v in pairs(arg) do str = str .. tostring(v) .. "\t" end local sendMsg = { event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 3} + data = { msg = ZZBase64.encode(str), type = 3 } } local sendStr = json.encode(sendMsg) debug_server:send(sendStr .. "__debugger_k0204__") end end end + --@endregion --@region 辅助方法 @@ -876,7 +879,7 @@ local function debugger_getFilePathInfo(file) file = file:gsub("/.\\", "/") file = file:gsub("\\", "/") file = file:gsub("//", "/") - + if file:find("@") == 1 then file = file:sub(2) @@ -977,7 +980,7 @@ local function debugger_dump(value, desciption, nesting) return tostring(v) end local traceback = debugger_strSplit(debug.traceback("", 2), "\n") - print("dump from: " .. debugger_strTrim(traceback[3])) + -- print("dump from: " .. debugger_strTrim(traceback[3])) local function _dump(value, desciption, indent, nest, keylen) desciption = desciption or "" local spc = "" @@ -1026,30 +1029,28 @@ local function debugger_dump(value, desciption, nesting) end _dump(value, desciption, "- ", 1) for i, line in ipairs(result) do - print(line) + -- print(line) end end --@endregion local function debugger_valueToString(v) - local vtype = type(v) + local vtype = type(v) local vstr = nil if (vtype == "userdata") then if (LuaDebugger.isFoxGloryProject) then - - return "userdata",vtype - + return "userdata", vtype else return tostring(v), vtype end elseif (vtype == "table" or vtype == "function" or vtype == "boolean") then local value = vtype - xpcall(function() + xpcall(function() value = tostring(v) - end,function() + end, function() value = vtype end) return value, vtype - elseif (vtype == "number" or vtype == "string" ) then + elseif (vtype == "number" or vtype == "string") then return v, vtype else return tostring(v), vtype @@ -1057,12 +1058,12 @@ local function debugger_valueToString(v) end local function debugger_setVarInfo(name, value) local valueStr, valueType = debugger_valueToString(value) - local nameStr,nameType = debugger_valueToString(name) - if(valueStr == nil) then + local nameStr, nameType = debugger_valueToString(name) + if (valueStr == nil) then valueStr = valueType end local valueInfo = { - name =nameStr, + name = nameStr, valueType = valueType, valueStr = ZZBase64.encode(valueStr) } @@ -1100,64 +1101,64 @@ local function debugger_getvalue(f) i = i + 1 end - return {locals = locals, ups = ups} + return { locals = locals, ups = ups } end --获取堆栈 debugger_stackInfo = function(ignoreCount, event) - local datas = {} - local stack = {} - local varInfos = {} - local funcs = {} - local index = 0 - for i = ignoreCount, 100 do - local source = getinfo(i) - local isadd = true - if (i == ignoreCount) then - local file = source.source - if (file:find(LuaDebugger.DebugLuaFie)) then - return + local datas = {} + local stack = {} + local varInfos = {} + local funcs = {} + local index = 0 + for i = ignoreCount, 100 do + local source = getinfo(i) + local isadd = true + if (i == ignoreCount) then + local file = source.source + if (file:find(LuaDebugger.DebugLuaFie)) then + return + end + if (file == "=[C]") then + isadd = false + end end - if (file == "=[C]") then - isadd = false + if not source then + break + end + if (isadd) then + local fullName, dir, fileName = debugger_getFilePathInfo(source.source) + local info = { + src = fullName, + scoreName = source.name, + currentline = source.currentline, + linedefined = source.linedefined, + what = source.what, + nameWhat = source.namewhat + } + index = i + local vars = debugger_getvalue(i + 1) + table.insert(stack, info) + table.insert(varInfos, vars) + table.insert(funcs, source.func) + end + if source.what == "main" then + break end end - if not source then - break - end - if (isadd) then - local fullName, dir, fileName = debugger_getFilePathInfo(source.source) - local info = { - src = fullName, - scoreName = source.name, - currentline = source.currentline, - linedefined = source.linedefined, - what = source.what, - nameWhat = source.namewhat - } - index = i - local vars = debugger_getvalue(i + 1) - table.insert(stack, info) - table.insert(varInfos, vars) - table.insert(funcs, source.func) - end - if source.what == "main" then - break - end - end - - local stackInfo = {stack = stack, vars = varInfos, funcs = funcs} - local data = { - stack = stackInfo.stack, - vars = stackInfo.vars, - funcs = stackInfo.funcs, - event = event, - funcsLength = #stackInfo.funcs, - upFunc = getinfo(ignoreCount - 3, "f").func - } - LuaDebugger.currentTempFunc = data.funcs[1] - return data -end + + local stackInfo = { stack = stack, vars = varInfos, funcs = funcs } + local data = { + stack = stackInfo.stack, + vars = stackInfo.vars, + funcs = stackInfo.funcs, + event = event, + funcsLength = #stackInfo.funcs, + upFunc = getinfo(ignoreCount - 3, "f").func + } + LuaDebugger.currentTempFunc = data.funcs[1] + return data + end --===========================点断信息================================================== --根据不同的游戏引擎进行定时获取断点信息 @@ -1167,37 +1168,37 @@ local function debugger_receiveDebugBreakInfo() if (jit) then if (LuaDebugger.debugLuaType ~= "jit") then local msg = "当前luajit版本为: " .. jit.version .. " 请使用LuaDebugjit 进行调试!" - print(msg) + -- print(msg) end end if (breakInfoSocket) then local msg, status = breakInfoSocket:receive() - if(LuaDebugger.isLaunch and status == "closed") then - os.exit() + if (LuaDebugger.isLaunch and status == "closed") then + os.exit() end if (msg) then local netData = json.decode(msg) if netData.event == LuaDebugger.event.S2C_SetBreakPoints then debugger_setBreak(netData.data) elseif netData.event == LuaDebugger.event.S2C_LoadLuaScript then - LuaDebugger.loadScriptBody = netData.data + LuaDebugger.loadScriptBody = netData.data debugger_exeLuaString() - debugger_sendMsg(breakInfoSocket,LuaDebugger.event.C2S_LoadLuaScript,LuaDebugger.loadScriptBody) + debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) elseif netData.event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.reLoadFileBody = netData.data LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) - print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + -- print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) LuaDebugger.reLoadFileBody.script = nil debugger_sendMsg( breakInfoSocket, LuaDebugger.event.C2S_ReLoadFile, { stack = LuaDebugger.reLoadFileBody - + } - ) - end + ) + end end end end @@ -1221,76 +1222,76 @@ local function splitFilePath(path) end debugger_setBreak = function(datas) - local breakInfos = LuaDebugger.breakInfos - for i, data in ipairs(datas) do - data.fileName = string.lower(data.fileName) - data.serverPath = string.lower(data.serverPath) - local breakInfo = breakInfos[data.fileName] - if (not breakInfo) then - breakInfos[data.fileName] = {} - breakInfo = breakInfos[data.fileName] - end - if (not data.breakDatas or #data.breakDatas == 0) then - breakInfo[data.serverPath] = nil - else - local fileBreakInfo = breakInfo[data.serverPath] - if (not fileBreakInfo) then - fileBreakInfo = { - pathNames = splitFilePath(data.serverPath), - --命中次數判斷計數器 - hitCounts = {} - } - breakInfo[data.serverPath] = fileBreakInfo + local breakInfos = LuaDebugger.breakInfos + for i, data in ipairs(datas) do + data.fileName = string.lower(data.fileName) + data.serverPath = string.lower(data.serverPath) + local breakInfo = breakInfos[data.fileName] + if (not breakInfo) then + breakInfos[data.fileName] = {} + breakInfo = breakInfos[data.fileName] end - local lineInfos = {} - for li, breakData in ipairs(data.breakDatas) do - lineInfos[breakData.line] = breakData - if (breakData.hitCondition and breakData.hitCondition ~= "") then - breakData.hitCondition = tonumber(breakData.hitCondition) - else - breakData.hitCondition = 0 + if (not data.breakDatas or #data.breakDatas == 0) then + breakInfo[data.serverPath] = nil + else + local fileBreakInfo = breakInfo[data.serverPath] + if (not fileBreakInfo) then + fileBreakInfo = { + pathNames = splitFilePath(data.serverPath), + --命中次數判斷計數器 + hitCounts = {} + } + breakInfo[data.serverPath] = fileBreakInfo end - if (not fileBreakInfo.hitCounts[breakData.line]) then - fileBreakInfo.hitCounts[breakData.line] = 0 + local lineInfos = {} + for li, breakData in ipairs(data.breakDatas) do + lineInfos[breakData.line] = breakData + if (breakData.hitCondition and breakData.hitCondition ~= "") then + breakData.hitCondition = tonumber(breakData.hitCondition) + else + breakData.hitCondition = 0 + end + if (not fileBreakInfo.hitCounts[breakData.line]) then + fileBreakInfo.hitCounts[breakData.line] = 0 + end + end + fileBreakInfo.lines = lineInfos + --這裡添加命中次數判斷 + for line, count in pairs(fileBreakInfo.hitCounts) do + if (not lineInfos[line]) then + fileBreakInfo.hitCounts[line] = nil + end end end - fileBreakInfo.lines = lineInfos - --這裡添加命中次數判斷 - for line, count in pairs(fileBreakInfo.hitCounts) do - if (not lineInfos[line]) then - fileBreakInfo.hitCounts[line] = nil - end + local count = 0 + for i, linesInfo in pairs(breakInfo) do + count = count + 1 + end + if (count == 0) then + breakInfos[data.fileName] = nil end end - local count = 0 - for i, linesInfo in pairs(breakInfo) do - count = count + 1 + --debugger_dump(breakInfos, "breakInfos", 6) + --检查是否需要断点 + local isHook = false + for k, v in pairs(breakInfos) do + isHook = true + break end - if (count == 0) then - breakInfos[data.fileName] = nil - end - end - --debugger_dump(breakInfos, "breakInfos", 6) - --检查是否需要断点 - local isHook = false - for k, v in pairs(breakInfos) do - isHook = true - break - end - --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 - if (isHook) then - if (not LuaDebugger.isHook) then - debug.sethook(debug_hook, "lrc") + --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 + if (isHook) then + if (not LuaDebugger.isHook) then + debug.sethook(debug_hook, "lrc") + end + LuaDebugger.isHook = true + else + if (LuaDebugger.isHook) then + debug.sethook() + end + LuaDebugger.isHook = false end - LuaDebugger.isHook = true - else - if (LuaDebugger.isHook) then - debug.sethook() - end - LuaDebugger.isHook = false end -end local function debugger_checkFileIsBreak(fileName) return LuaDebugger.breakInfos[fileName] end @@ -1322,31 +1323,30 @@ function debugger_conditionStr(condition, vars, callBack) currentTabble[k] = v end end - setmetatable(currentTabble, {__index = _G}) + setmetatable(currentTabble, { __index = _G }) local fun = loadstring("return " .. condition) setfenv(fun, currentTabble) return fun() end local status, - msg = + msg = xpcall( - loadScript, - function(error) - print(error) - end - ) + loadScript, + function(error) + -- print(error) + end + ) if (status and msg) then callBack() end end + --执行lua字符串 debugger_exeLuaString = function() - local function loadScript() - local script = LuaDebugger.loadScriptBody.script if (LuaDebugger.loadScriptBody.isBreak) then - local currentTabble = {_G = _G} + local currentTabble = { _G = _G } local frameId = LuaDebugger.loadScriptBody.frameId frameId = frameId local func = LuaDebugger.currentDebuggerData.funcs[frameId] @@ -1359,8 +1359,8 @@ debugger_exeLuaString = function() for k, v in pairs(locals) do currentTabble[k] = v end - setmetatable(currentTabble, {__index = _G}) - + setmetatable(currentTabble, { __index = _G }) + local fun = loadstring(script) setfenv(fun, currentTabble) fun() @@ -1370,54 +1370,51 @@ debugger_exeLuaString = function() end end local status, - msg = + msg = xpcall( - loadScript, - function(error) - - -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) - end - ) - LuaDebugger.loadScriptBody.script = nil + loadScript, + function(error) + -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) + end + ) + LuaDebugger.loadScriptBody.script = nil if (LuaDebugger.loadScriptBody.isBreak) then - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack - end + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event + .C2S_HITBreakPoint) + LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack + end LuaDebugger.loadScriptBody.complete = true - end --@region 调试中修改变量值 --根据key 值在 value 查找 -local function debugger_getTablekey(key,keyType,value) - if(keyType == -1) then +local function debugger_getTablekey(key, keyType, value) + if (keyType == -1) then return key - elseif(keyType == 1) then + elseif (keyType == 1) then return tonumber(key) - elseif(keyType == 2) then + elseif (keyType == 2) then local valueKey = nil - for k,v in pairs(value) do + for k, v in pairs(value) do local nameType = type(k) - if(nameType == "userdata" or nameType == "table") then + if (nameType == "userdata" or nameType == "table") then if (not LuaDebugger.isFoxGloryProject) then valueKey = tostring(k) - if(key == valueKey) then + if (key == valueKey) then return k end break end end end - end end local function debugger_setVarValue(server, data) - local newValue = nil - local level = LuaDebugger.serVarLevel+LuaDebugger.setVarBody.frameId + local level = LuaDebugger.serVarLevel + LuaDebugger.setVarBody.frameId local firstKeyName = data.keys[1] --@region vars check local localValueChangeIndex = -1 @@ -1432,7 +1429,7 @@ local function debugger_setVarValue(server, data) if not name then break end - if(firstKeyName == name) then + if (firstKeyName == name) then localValueChangeIndex = i oldValue = value end @@ -1446,11 +1443,11 @@ local function debugger_setVarValue(server, data) local ups = {} while func do -- check for func as it may be nil for tail calls local name, value = debug.getupvalue(func, i) - + if not name then break end - if(localValueChangeIndex == -1 and firstKeyName == name) then + if (localValueChangeIndex == -1 and firstKeyName == name) then upValueFun = func oldValue = value upValueChangeIndex = i @@ -1462,9 +1459,9 @@ local function debugger_setVarValue(server, data) end i = i + 1 end ---@endregion - local vars = {locals = locals, ups = ups} - + --@endregion + local vars = { locals = locals, ups = ups } + local function loadScript() local currentTabble = {} local locals = vars.locals @@ -1480,58 +1477,56 @@ local function debugger_setVarValue(server, data) currentTabble[k] = v end end - setmetatable(currentTabble, {__index = _G}) + setmetatable(currentTabble, { __index = _G }) local fun = loadstring("return " .. data.value) setfenv(fun, currentTabble) newValue = fun() end local status, - msg = + msg = xpcall( - loadScript, - function(error) - print(error, "============================") - end - ) - + loadScript, + function(error) + -- print(error, "============================") + end + ) + local i = 1 - + -- local 查找并替换 local keyLength = #data.keys - - if(keyLength == 1) then - if(localValueChangeIndex ~= -1) then - + + if (keyLength == 1) then + if (localValueChangeIndex ~= -1) then debug.setlocal(level, localValueChangeIndex, newValue) - elseif(upValueFun ~= nil) then - debug.setupvalue( upValueFun, upValueChangeIndex, newValue ) + elseif (upValueFun ~= nil) then + debug.setupvalue(upValueFun, upValueChangeIndex, newValue) else --全局变量查找 - if(_G[firstKeyName]) then + if (_G[firstKeyName]) then _G[firstKeyName] = newValue end end else - if(not oldValue) then - if(_G[firstKeyName]) then + if (not oldValue) then + if (_G[firstKeyName]) then oldValue = _G[firstKeyName] end end local tempValue = oldValue - for i=2,keyLength-1 do - if(tempValue) then - oldValue = oldValue[debugger_getTablekey(data.keys[i],data.numberTypes[i],oldValue)] + for i = 2, keyLength - 1 do + if (tempValue) then + oldValue = oldValue[debugger_getTablekey(data.keys[i], data.numberTypes[i], oldValue)] end end - if(tempValue) then - oldValue[debugger_getTablekey(data.keys[keyLength],data.numberTypes[keyLength],oldValue)] = newValue + if (tempValue) then + oldValue[debugger_getTablekey(data.keys[keyLength], data.numberTypes[keyLength], oldValue)] = newValue end end - local varInfo = debugger_setVarInfo(data.varName, newValue) + local varInfo = debugger_setVarInfo(data.varName, newValue) data.varInfo = varInfo - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - end --@endregion @@ -1541,44 +1536,44 @@ end --调试修改变量值统一的 _resume checkSetVar = function() - if (LuaDebugger.isSetVar) then - LuaDebugger.isSetVar = false - debugger_setVarValue(debug_server,LuaDebugger.setVarBody) - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.setVarBody) - xpcall( - checkSetVar, - function(error) - print("设置变量", error) - end - ) - elseif(LuaDebugger.isLoadLuaScript) then - LuaDebugger.isLoadLuaScript = false - debugger_exeLuaString() - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("执行代码", error) - end - ) - elseif(LuaDebugger.isReLoadFile) then - LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) - print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) - LuaDebugger.reLoadFileBody.script = nil - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("重新加载文件", error) - end - ) + if (LuaDebugger.isSetVar) then + LuaDebugger.isSetVar = false + debugger_setVarValue(debug_server, LuaDebugger.setVarBody) + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.setVarBody) + xpcall( + checkSetVar, + function(error) + -- print("设置变量", error) + end + ) + elseif (LuaDebugger.isLoadLuaScript) then + LuaDebugger.isLoadLuaScript = false + debugger_exeLuaString() + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("执行代码", error) + end + ) + elseif (LuaDebugger.isReLoadFile) then + LuaDebugger.isReLoadFile = false + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + -- print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.script = nil + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("重新加载文件", error) + end + ) + end end -end - + local function getSource(source) @@ -1598,7 +1593,7 @@ local function debugger_GeVarInfoBytUserData(server, var) local fileds = LuaDebugTool.getUserDataInfo(var) local varInfos = {} - + --c# vars for i = 1, fileds.Count do @@ -1619,18 +1614,18 @@ end local function debugger_getValueByScript(value, script) local val = nil local status, - msg = + msg = xpcall( - function() - local fun = loadstring("return " .. script) - setfenv(fun, value) - val = fun() - end, - function(error) - print(error, "====>") - val = nil - end - ) + function() + local fun = loadstring("return " .. script) + setfenv(fun, value) + val = fun() + end, + function(error) + -- print(error, "====>") + val = nil + end + ) return val end @@ -1735,7 +1730,7 @@ end local function debugger_searchVarByKeys(value, keys, searckKeys) local index, val = debugger_getVarByKeys(value, searckKeys, 1) - if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then + if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then return index, val end if (val) then @@ -1863,9 +1858,9 @@ local function debugger_sendTableValues(value, server, variablesReference, debug if (valueType == "userdata") then m = getmetatable(value) - + vinfos = debugger_sendTableField(value, vinfos, server, variablesReference, debugSpeedIndex, valueType) - + if (LuaDebugTool) then local varInfos = debugger_GeVarInfoBytUserData(server, value, variablesReference, debugSpeedIndex) @@ -1894,7 +1889,6 @@ local function debugger_sendTableValues(value, server, variablesReference, debug vinfos = {} end end - end else m = getmetatable(value) @@ -1944,7 +1938,6 @@ local function debugger_getBreakVar(body, server) if (value) then local valueType = type(value) if (valueType == "table" or valueType == "userdata") then - debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) else if (valueType == "function") then @@ -1979,9 +1972,9 @@ local function debugger_getBreakVar(body, server) xpcall( exe, function(error) - -- print("获取变量错误 错误消息-----------------") - -- print(error) - -- print(debug.traceback("", 2)) + -- -- print("获取变量错误 错误消息-----------------") + -- -- print(error) + -- -- print(debug.traceback("", 2)) debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, @@ -2018,25 +2011,24 @@ local function debugger_loop(server) while true do local line, status = server:receive() if (status == "closed") then - if(LuaDebugger.isLaunch) then - os.exit() - else - debug.sethook() - coroutine.yield() - end + if (LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end end if (line) then local netData = json.decode(line) local event = netData.event local body = netData.data if (event == LuaDebugger.event.S2C_DebugClose) then - if(LuaDebugger.isLaunch) then - os.exit() - else - debug.sethook() - coroutine.yield() - end - + if (LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end elseif event == LuaDebugger.event.S2C_SetBreakPoints then --设置断点信息 local function setB() @@ -2045,7 +2037,7 @@ local function debugger_loop(server) xpcall( setB, function(error) - print(error) + -- print(error) end ) elseif event == LuaDebugger.event.S2C_RUN then --开始运行 @@ -2137,8 +2129,8 @@ local function debugger_loop(server) stack = data, eventType = data.eventType } - ) - elseif event == LuaDebugger.event.S2C_ReLoadFile then + ) + elseif event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.isReLoadFile = true LuaDebugger.reLoadFileBody = body local data = coroutine.yield() @@ -2156,29 +2148,26 @@ local function debugger_loop(server) end coro_debugger = coroutine.create(debugger_loop) debug_hook = function(event, line) - - if(not LuaDebugger.isHook) then + if (not LuaDebugger.isHook) then return end - - if(LuaDebugger.Run) then - if(event == "line") then + + if (LuaDebugger.Run) then + if (event == "line") then local isCheck = false for k, breakInfo in pairs(LuaDebugger.breakInfos) do - for bk, linesInfo in pairs(breakInfo) do - - if(linesInfo.lines and linesInfo.lines[line]) then + if (linesInfo.lines and linesInfo.lines[line]) then isCheck = true break end end - if(isCheck) then - break - end + if (isCheck) then + break + end end - if(not isCheck) then + if (not isCheck) then return end else @@ -2200,8 +2189,8 @@ debug_hook = function(event, line) else if (LuaDebugger.currentDebuggerData.funcs[2] == tempFun) then local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) - --挂起等待调试器作出反应 - + --挂起等待调试器作出反应 + _resume(coro_debugger, data) checkSetVar() end @@ -2209,7 +2198,7 @@ debug_hook = function(event, line) return end -- debugger_dump(LuaDebugger,"LuaDebugger") - -- print(LuaDebugger.StepNextLevel,"LuaDebugger.StepNextLevel") + -- -- print(LuaDebugger.StepNextLevel,"LuaDebugger.StepNextLevel") local file = nil if (event == "call") then -- end @@ -2217,7 +2206,7 @@ debug_hook = function(event, line) if (not LuaDebugger.Run) then LuaDebugger.StepNextLevel = LuaDebugger.StepNextLevel + 1 end - -- print("stepIn",LuaDebugger.StepNextLevel) + -- -- print("stepIn",LuaDebugger.StepNextLevel) local stepInfo = getinfo(2, "S") local source = stepInfo.source @@ -2254,12 +2243,11 @@ debug_hook = function(event, line) LuaDebugger.currentFileName = file end file = LuaDebugger.currentFileName - + --判断断点 local breakInfo = LuaDebugger.breakInfos[file] local breakData = nil if (breakInfo) then - local ischeck = false for k, lineInfo in pairs(breakInfo) do local lines = lineInfo.lines @@ -2268,7 +2256,7 @@ debug_hook = function(event, line) break end end - + if (ischeck) then --并且在断点中 local info = stepInfo @@ -2276,7 +2264,7 @@ debug_hook = function(event, line) info = getinfo(2) end local hitPathNames = splitFilePath(LuaDebugger.currentLineFile) - + local hitCounts = {} local debugHitCounts = nil for k, lineInfo in pairs(breakInfo) do @@ -2288,7 +2276,7 @@ debug_hook = function(event, line) --判断路径 hitCounts[k] = 0 local hitPathNamesCount = #hitPathNames - + local pathNamesCount = #pathNames local checkCount = 0; while (true) do @@ -2299,13 +2287,13 @@ debug_hook = function(event, line) end pathNamesCount = pathNamesCount - 1 hitPathNamesCount = hitPathNamesCount - 1 - checkCount = checkCount+1 - + checkCount = checkCount + 1 + if (pathNamesCount <= 0 or hitPathNamesCount <= 0) then break end end - if(checkCount>0) then + if (checkCount > 0) then break; end else @@ -2354,8 +2342,8 @@ debug_hook = function(event, line) local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) -- 挂起等待调试器作出反应 if (data) then - LuaDebugger.currentTempFunc = data.funcs[1] - + LuaDebugger.currentTempFunc = data.funcs[1] + _resume(coro_debugger, data) checkSetVar() return @@ -2384,8 +2372,8 @@ end local function debugger_xpcall() --调用 coro_debugger 并传入 参数 local data = debugger_stackInfo(4, LuaDebugger.event.C2S_HITBreakPoint) - if(data.stack and data.stack[1]) then - data.stack[1].isXpCall = true + if (data.stack and data.stack[1]) then + data.stack[1].isXpCall = true end --挂起等待调试器作出反应 _resume(coro_debugger, data) @@ -2396,8 +2384,8 @@ local function start() local fullName, dirName, fileName = debugger_getFilePathInfo(getinfo(1).source) LuaDebugger.DebugLuaFie = fileName local socket = createSocket() - print(controller_host) - print(controller_port) + -- print(controller_host) + -- print(controller_port) local server = socket.connect(controller_host, controller_port) debug_server = server @@ -2427,33 +2415,33 @@ local function start() debug.sethook(debug_hook, "lrc") end, function(error) - print("error:", error) + -- print("error:", error) end ) if (jit) then if (LuaDebugger.debugLuaType ~= "jit") then - print("error======================================================") + -- print("error======================================================") local msg = "当前luajit版本为: " .. jit.version .. " 请使用LuaDebugjit 进行调试!" - print(msg) + -- print(msg) end end - _resume(coro_debugger, server) + _resume(coro_debugger, server) end end end function StartDebug(host, port) if (not host) then - print("error host nil") + -- print("error host nil") end if (not port) then - print("error prot nil") + -- print("error prot nil") end if (type(host) ~= "string") then - print("error host not string") + -- print("error host not string") end if (type(port) ~= "number") then - print("error host not number") + -- print("error host not number") end controller_host = host controller_port = port @@ -2461,7 +2449,7 @@ function StartDebug(host, port) start, function(error) -- body - print(error) + -- print(error) end ) return debugger_receiveDebugBreakInfo, debugger_xpcall @@ -2478,25 +2466,25 @@ ZZBase64.__code = { 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', }; ZZBase64.__decode = {} -for k,v in pairs(ZZBase64.__code) do - ZZBase64.__decode[string.byte(v,1)] = k - 1 +for k, v in pairs(ZZBase64.__code) do + ZZBase64.__decode[string.byte(v, 1)] = k - 1 end function ZZBase64.encode(text) - local len = string.len(text) - local left = len % 3 - len = len - left - local res = {} - local index = 1 + local len = string.len(text) + local left = len % 3 + len = len - left + local res = {} + local index = 1 for i = 1, len, 3 do - local a = string.byte(text, i ) + local a = string.byte(text, i) local b = string.byte(text, i + 1) local c = string.byte(text, i + 2) -- num = a<<16 + b<<8 + c local num = a * 65536 + b * 256 + c for j = 1, 4 do --tmp = num >> ((4 -j) * 6) - local tmp = math.floor(num / (2 ^ ((4-j) * 6))) + local tmp = math.floor(num / (2 ^ ((4 - j) * 6))) --curPos = tmp&0x3f local curPos = tmp % 64 + 1 res[index] = ZZBase64.__code[curPos] @@ -2516,7 +2504,7 @@ function ZZBase64.__left2(res, index, text, len) local num1 = string.byte(text, len + 1) num1 = num1 * 1024 --lshift 10 local num2 = string.byte(text, len + 2) - num2 = num2 * 4 --lshift 2 + num2 = num2 * 4 --lshift 2 local num = num1 + num2 local tmp1 = math.floor(num / 4096) --rShift 12 @@ -2533,13 +2521,13 @@ function ZZBase64.__left2(res, index, text, len) res[index + 3] = "=" end -function ZZBase64.__left1(res, index,text, len) +function ZZBase64.__left1(res, index, text, len) local num = string.byte(text, len + 1) num = num * 16 local tmp = math.floor(num / 64) local curPos = tmp % 64 + 1 - res[index ] = ZZBase64.__code[curPos] + res[index] = ZZBase64.__code[curPos] curPos = num % 64 + 1 res[index + 1] = ZZBase64.__code[curPos] @@ -2562,11 +2550,11 @@ function ZZBase64.decode(text) local res = {} local index = 1 local decode = ZZBase64.__decode - for i =1, len, 4 do - local a = decode[string.byte(text,i )] - local b = decode[string.byte(text,i + 1)] - local c = decode[string.byte(text,i + 2)] - local d = decode[string.byte(text,i + 3)] + for i = 1, len, 4 do + local a = decode[string.byte(text, i)] + local b = decode[string.byte(text, i + 1)] + local c = decode[string.byte(text, i + 2)] + local d = decode[string.byte(text, i + 3)] --num = a<<18 + b<<12 + c<<6 + d local num = a * 262144 + b * 4096 + c * 64 + d @@ -2575,7 +2563,7 @@ function ZZBase64.decode(text) num = math.floor(num / 256) local f = string.char(num % 256) num = math.floor(num / 256) - res[index ] = string.char(num % 256) + res[index] = string.char(num % 256) res[index + 1] = f res[index + 2] = e index = index + 3 @@ -2611,7 +2599,4 @@ function ZZBase64.__decodeLeft2(res, index, text, len) res[index] = string.char(num) end - - - return StartDebug diff --git a/lua_probject/base_project/LuaDebugjit.lua b/lua_probject/base_project/LuaDebugjit.lua index 6ba9f888..c5a8613b 100644 --- a/lua_probject/base_project/LuaDebugjit.lua +++ b/lua_probject/base_project/LuaDebugjit.lua @@ -1,7 +1,7 @@ -local debugger_reLoadFile =nil -xpcall(function() +local debugger_reLoadFile = nil +xpcall(function() debugger_reLoadFile = require("luaideReLoadFile") -end,function() +end, function() debugger_reLoadFile = function() print("未实现代码重载") end end) local sethook = debug.sethook @@ -13,165 +13,165 @@ local checkSetVar = nil local loadstring_ = nil local debugger_sendMsg = nil if (loadstring) then -loadstring_ = loadstring + loadstring_ = loadstring else -loadstring_ = load + loadstring_ = load end local ZZBase64 = {} local LuaDebugTool_ = nil if (LuaDebugTool) then - LuaDebugTool_ = LuaDebugTool + LuaDebugTool_ = LuaDebugTool elseif (CS and CS.LuaDebugTool) then - LuaDebugTool_ = CS.LuaDebugTool + LuaDebugTool_ = CS.LuaDebugTool end local LuaDebugTool = LuaDebugTool_ local loadstring = loadstring_ local getinfo = debug.getinfo local function createSocket() - local base = _G - local string = require("string") - local math = require("math") - local socket = require("socket.core") - - local _M = socket - - ----------------------------------------------------------------------------- - -- Exported auxiliar functions - ----------------------------------------------------------------------------- - function _M.connect4(address, port, laddress, lport) - return socket.connect(address, port, laddress, lport, "inet") - end - - function _M.connect6(address, port, laddress, lport) - return socket.connect(address, port, laddress, lport, "inet6") - end + local base = _G + local string = require("string") + local math = require("math") + local socket = require("socket.core") - if (not _M.connect) then - function _M.connect(address, port, laddress, lport) - local sock, err = socket.tcp() - if not sock then - return nil, err - end - if laddress then - local res, err = sock:bind(laddress, lport, -1) - if not res then - return nil, err - end - end - local res, err = sock:connect(address, port) - if not res then + local _M = socket + + ----------------------------------------------------------------------------- + -- Exported auxiliar functions + ----------------------------------------------------------------------------- + function _M.connect4(address, port, laddress, lport) + return socket.connect(address, port, laddress, lport, "inet") + end + + function _M.connect6(address, port, laddress, lport) + return socket.connect(address, port, laddress, lport, "inet6") + end + + if (not _M.connect) then + function _M.connect(address, port, laddress, lport) + local sock, err = socket.tcp() + if not sock then return nil, err end - return sock - end - end - function _M.bind(host, port, backlog) - if host == "*" then + if laddress then + local res, err = sock:bind(laddress, lport, -1) + if not res then + return nil, err + end + end + local res, err = sock:connect(address, port) + if not res then + return nil, err + end + return sock + end + end + function _M.bind(host, port, backlog) + if host == "*" then host = "0.0.0.0" end local addrinfo, err = socket.dns.getaddrinfo(host) if not addrinfo then return nil, err end - local sock, res - err = "no info on address" - for i, alt in base.ipairs(addrinfo) do - if alt.family == "inet" then - sock, err = socket.tcp4() - else - sock, err = socket.tcp6() - end - if not sock then + local sock, res + err = "no info on address" + for i, alt in base.ipairs(addrinfo) do + if alt.family == "inet" then + sock, err = socket.tcp4() + else + sock, err = socket.tcp6() + end + if not sock then return nil, err end - sock:setoption("reuseaddr", true) - res, err = sock:bind(alt.addr, port) - if not res then - sock:close() - else - res, err = sock:listen(backlog) - if not res then - sock:close() - else - return sock - end - end - end - return nil, err - end - - _M.try = _M.newtry() - - function _M.choose(table) - return function(name, opt1, opt2) - if base.type(name) ~= "string" then - name, opt1, opt2 = "default", name, opt1 - end - local f = table[name or "nil"] - if not f then + sock:setoption("reuseaddr", true) + res, err = sock:bind(alt.addr, port) + if not res then + sock:close() + else + res, err = sock:listen(backlog) + if not res then + sock:close() + else + return sock + end + end + end + return nil, err + end + + _M.try = _M.newtry() + + function _M.choose(table) + return function(name, opt1, opt2) + if base.type(name) ~= "string" then + name, opt1, opt2 = "default", name, opt1 + end + local f = table[name or "nil"] + if not f then base.error("unknown key (" .. base.tostring(name) .. ")", 3) else return f(opt1, opt2) end - end - end - - ----------------------------------------------------------------------------- - -- Socket sources and sinks, conforming to LTN12 - ----------------------------------------------------------------------------- - -- create namespaces inside LuaSocket namespace - local sourcet, sinkt = {}, {} - _M.sourcet = sourcet - _M.sinkt = sinkt - - _M.BLOCKSIZE = 2048 - - sinkt["close-when-done"] = - function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if not chunk then - sock:close() - return 1 - else - return sock:send(chunk) - end - end - } - ) + end end + ----------------------------------------------------------------------------- + -- Socket sources and sinks, conforming to LTN12 + ----------------------------------------------------------------------------- + -- create namespaces inside LuaSocket namespace + local sourcet, sinkt = {}, {} + _M.sourcet = sourcet + _M.sinkt = sinkt + + _M.BLOCKSIZE = 2048 + + sinkt["close-when-done"] = + function(sock) + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() + end + }, + { + __call = function(self, chunk, err) + if not chunk then + sock:close() + return 1 + else + return sock:send(chunk) + end + end + } + ) + end + sinkt["keep-open"] = function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if chunk then - return sock:send(chunk) - else - return 1 + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - end - } - ) - end + }, + { + __call = function(self, chunk, err) + if chunk then + return sock:send(chunk) + else + return 1 + end + end + } + ) + end sinkt["default"] = sinkt["keep-open"] @@ -179,133 +179,133 @@ local function createSocket() sourcet["by-length"] = function(sock, length) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if length <= 0 then - return nil + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local size = math.min(socket.BLOCKSIZE, length) - local chunk, err = sock:receive(size) - if err then - return nil, err + }, + { + __call = function() + if length <= 0 then + return nil + end + local size = math.min(socket.BLOCKSIZE, length) + local chunk, err = sock:receive(size) + if err then + return nil, err + end + length = length - string.len(chunk) + return chunk end - length = length - string.len(chunk) - return chunk - end - } - ) - end + } + ) + end sourcet["until-closed"] = function(sock) - local done - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if done then - return nil + local done + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local chunk, err, partial = sock:receive(socket.BLOCKSIZE) - if not err then - return chunk - elseif err == "closed" then - sock:close() - done = 1 - return partial - else - return nil, err + }, + { + __call = function() + if done then + return nil + end + local chunk, err, partial = sock:receive(socket.BLOCKSIZE) + if not err then + return chunk + elseif err == "closed" then + sock:close() + done = 1 + return partial + else + return nil, err + end end - end - } - ) - end - - sourcet["default"] = sourcet["until-closed"] - - _M.source = _M.choose(sourcet) - - return _M + } + ) + end + + sourcet["default"] = sourcet["until-closed"] + + _M.source = _M.choose(sourcet) + + return _M end local function createJson() - local math = require("math") - local string = require("string") - local table = require("table") - local object = nil - ----------------------------------------------------------------------------- - -- Module declaration - ----------------------------------------------------------------------------- - local json = {} -- Public namespace + local math = require("math") + local string = require("string") + local table = require("table") + local object = nil + ----------------------------------------------------------------------------- + -- Module declaration + ----------------------------------------------------------------------------- + local json = {} -- Public namespace local json_private = {} -- Private namespace - - -- Public constants - json.EMPTY_ARRAY = {} - json.EMPTY_OBJECT = {} - -- Public functions - -- Private functions - local decode_scanArray - local decode_scanComment - local decode_scanConstant - local decode_scanNumber - local decode_scanObject - local decode_scanString - local decode_scanWhitespace - local encodeString - local isArray - local isEncodable - - ----------------------------------------------------------------------------- - -- PUBLIC FUNCTIONS - ----------------------------------------------------------------------------- - --- Encodes an arbitrary Lua object / variable. - -- @param v The Lua object / variable to be JSON encoded. - -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) - function json.encode(v) - -- Handle nil values - if v == nil then - return "null" - end - - local vtype = type(v) - - -- Handle strings - if vtype == "string" then + -- Public constants + json.EMPTY_ARRAY = {} + json.EMPTY_OBJECT = {} + -- Public functions + + -- Private functions + local decode_scanArray + local decode_scanComment + local decode_scanConstant + local decode_scanNumber + local decode_scanObject + local decode_scanString + local decode_scanWhitespace + local encodeString + local isArray + local isEncodable + + ----------------------------------------------------------------------------- + -- PUBLIC FUNCTIONS + ----------------------------------------------------------------------------- + --- Encodes an arbitrary Lua object / variable. + -- @param v The Lua object / variable to be JSON encoded. + -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) + function json.encode(v) + -- Handle nil values + if v == nil then + return "null" + end + + local vtype = type(v) + + -- Handle strings + if vtype == "string" then return '"' .. json_private.encodeString(v) .. '"' -- Need to handle encoding in string end - - -- Handle booleans - if vtype == "number" or vtype == "boolean" then + + -- Handle booleans + if vtype == "number" or vtype == "boolean" then return tostring(v) end - - -- Handle tables - if vtype == "table" then - local rval = {} - -- Consider arrays separately - local bArray, maxCount = isArray(v) - if bArray then - for i = 1, maxCount do - table.insert(rval, json.encode(v[i])) - end - else -- An object, not an array + + -- Handle tables + if vtype == "table" then + local rval = {} + -- Consider arrays separately + local bArray, maxCount = isArray(v) + if bArray then + for i = 1, maxCount do + table.insert(rval, json.encode(v[i])) + end + else -- An object, not an array for i, j in pairs(v) do if isEncodable(i) and isEncodable(j) then table.insert(rval, '"' .. json_private.encodeString(i) .. '":' .. json.encode(j)) @@ -317,23 +317,23 @@ local function createJson() else return "{" .. table.concat(rval, ",") .. "}" end - end - - -- Handle null values - if vtype == "function" and v == json.null then + end + + -- Handle null values + if vtype == "function" and v == json.null then return "null" end assert(false, "encode attempt to encode unsupported type " .. vtype .. ":" .. tostring(v)) end - - --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. - -- @param s The string to scan. - -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. - -- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, - -- and the position of the first character after - -- the scanned JSON object. - function json.decode(s, startPos) + + --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. + -- @param s The string to scan. + -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. + -- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, + -- and the position of the first character after + -- the scanned JSON object. + function json.decode(s, startPos) startPos = startPos and startPos or 1 startPos = decode_scanWhitespace(s, startPos) assert(startPos <= string.len(s), "Unterminated JSON encoded object found at position in [" .. s .. "]") @@ -366,18 +366,19 @@ local function createJson() function json.null() return json.null -- so json.null() will also return null ;-) end - ----------------------------------------------------------------------------- - -- Internal, PRIVATE functions. - -- Following a Python-like convention, I have prefixed all these 'PRIVATE' - -- functions with an underscore. - ----------------------------------------------------------------------------- - --- Scans an array from JSON into a Lua object - -- startPos begins at the start of the array. - -- Returns the array and the next starting position - -- @param s The string being scanned. - -- @param startPos The starting position for the scan. - -- @return table, int The scanned array as a table, and the position of the next character to scan. - function decode_scanArray(s, startPos) + + ----------------------------------------------------------------------------- + -- Internal, PRIVATE functions. + -- Following a Python-like convention, I have prefixed all these 'PRIVATE' + -- functions with an underscore. + ----------------------------------------------------------------------------- + --- Scans an array from JSON into a Lua object + -- startPos begins at the start of the array. + -- Returns the array and the next starting position + -- @param s The string being scanned. + -- @param startPos The starting position for the scan. + -- @return table, int The scanned array as a table, and the position of the next character to scan. + function decode_scanArray(s, startPos) local array = {} -- The return value local stringLen = string.len(s) assert( @@ -423,8 +424,8 @@ local function createJson() -- @return object, int The object (true, false or nil) and the position at which the next character should be -- scanned. function decode_scanConstant(s, startPos) - local consts = {["true"] = true, ["false"] = false, ["null"] = nil} - local constNames = {"true", "false", "null"} + local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } + local constNames = { "true", "false", "null" } for i, k in pairs(constNames) do if string.sub(s, startPos, startPos + string.len(k) - 1) == k then @@ -573,7 +574,7 @@ local function createJson() assert( string.find(s, startChar, j + 1), "String decoding failed: missing closing " .. - startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" + startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" ) return table.concat(t, ""), j + 2 -- END SoniEx2 @@ -649,13 +650,13 @@ local function createJson() if v ~= (t.n or #t) then return false end -- False if n does not hold the number of elements - else -- Else of (k=='n') + else -- Else of (k=='n') if isEncodable(v) then return false end end -- End of (k~='n') - end -- End of k,v not an indexed pair - end -- End of loop across all pairs + end -- End of k,v not an indexed pair + end -- End of loop across all pairs return true, maxIndex end @@ -677,64 +678,64 @@ local debug_server = nil local breakInfoSocket = nil local json = createJson() local LuaDebugger = { - fileMaps = {}, - Run = true, --表示正常运行只检测断点 - StepIn = false, - StepNext = false, - StepOut = false, - breakInfos = {}, - runTimeType = nil, - isHook = true, - pathCachePaths = {}, - isProntToConsole = 1, - isDebugPrint = true, - hookType = "lrc", - stepNextFun = nil, - DebugLuaFie = "", - runLineCount = 0, - --分割字符串缓存 - splitFilePaths = {}, - version="0.9.3", + fileMaps = {}, + Run = true, --表示正常运行只检测断点 + StepIn = false, + StepNext = false, + StepOut = false, + breakInfos = {}, + runTimeType = nil, + isHook = true, + pathCachePaths = {}, + isProntToConsole = 1, + isDebugPrint = true, + hookType = "lrc", + stepNextFun = nil, + DebugLuaFie = "", + runLineCount = 0, + --分割字符串缓存 + splitFilePaths = {}, + version = "0.9.3", serVarLevel = 4 } local debug_hook = nil local _resume = coroutine.resume coroutine.resume = function(co, ...) - if (LuaDebugger.isHook) then + if (LuaDebugger.isHook) then if coroutine.status(co) ~= "dead" then debug.sethook(co, debug_hook, "lrc") - end + end end return _resume(co, ...) end LuaDebugger.event = { - S2C_SetBreakPoints = 1, - C2S_SetBreakPoints = 2, - S2C_RUN = 3, - C2S_HITBreakPoint = 4, - S2C_ReqVar = 5, - C2S_ReqVar = 6, - --单步跳过请求 - S2C_NextRequest = 7, - --单步跳过反馈 - C2S_NextResponse = 8, - -- 单步跳过 结束 没有下一步 - C2S_NextResponseOver = 9, - --单步跳入 - S2C_StepInRequest = 10, - C2S_StepInResponse = 11, - --单步跳出 - S2C_StepOutRequest = 12, - --单步跳出返回 - C2S_StepOutResponse = 13, - --打印 - C2S_LuaPrint = 14, - S2C_LoadLuaScript = 16, - C2S_SetSocketName = 17, - C2S_LoadLuaScript = 18, - C2S_DebugXpCall = 20, - S2C_DebugClose = 21, + S2C_SetBreakPoints = 1, + C2S_SetBreakPoints = 2, + S2C_RUN = 3, + C2S_HITBreakPoint = 4, + S2C_ReqVar = 5, + C2S_ReqVar = 6, + --单步跳过请求 + S2C_NextRequest = 7, + --单步跳过反馈 + C2S_NextResponse = 8, + -- 单步跳过 结束 没有下一步 + C2S_NextResponseOver = 9, + --单步跳入 + S2C_StepInRequest = 10, + C2S_StepInResponse = 11, + --单步跳出 + S2C_StepOutRequest = 12, + --单步跳出返回 + C2S_StepOutResponse = 13, + --打印 + C2S_LuaPrint = 14, + S2C_LoadLuaScript = 16, + C2S_SetSocketName = 17, + C2S_LoadLuaScript = 18, + C2S_DebugXpCall = 20, + S2C_DebugClose = 21, S2C_SerVar = 24, C2S_SerVar = 25, S2C_ReLoadFile = 26, @@ -742,27 +743,27 @@ LuaDebugger.event = { } --@region print function print(...) - if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then debugger_print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} - end - for k, v in pairs(arg) do - str = str .. tostring(v) .. "\t" - end - local sendMsg = { - event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 1} - } - local sendStr = json.encode(sendMsg) - debug_server:send(sendStr .. "__debugger_k0204__") - end - end + arg = { "nil" } + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = { msg = ZZBase64.encode(str), type = 1 } + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end end function luaIdePrintWarn(...) @@ -771,46 +772,48 @@ function luaIdePrintWarn(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} - end - for k, v in pairs(arg) do - str = str .. tostring(v) .. "\t" - end - local sendMsg = { - event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 2} - } - local sendStr = json.encode(sendMsg) - debug_server:send(sendStr .. "__debugger_k0204__") - end - end + arg = { "nil" } + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = { msg = ZZBase64.encode(str), type = 2 } + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end end + function luaIdePrintErr(...) if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then debugger_print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} - end - for k, v in pairs(arg) do - str = str .. tostring(v) .. "\t" - end - local sendMsg = { - event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 3} - } - local sendStr = json.encode(sendMsg) - debug_server:send(sendStr .. "__debugger_k0204__") - end - end + arg = { "nil" } + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = { msg = ZZBase64.encode(str), type = 3 } + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end end + --@endregion --@region 辅助方法 @@ -841,23 +844,23 @@ local function debugger_convertParentDir(dir) end end -local function debugger_getFilePathInfo(file) - local fileName = nil +local function debugger_getFilePathInfo(file) + local fileName = nil local dir = nil file = file:gsub("/.\\", "/") - file = file:gsub("\\", "/") - file = file:gsub("//", "/") - + file = file:gsub("\\", "/") + file = file:gsub("//", "/") - if file:find("@") == 1 then + + if file:find("@") == 1 then file = file:sub(2) - end - local findex = file:find("%./") - if (findex == 1) then + end + local findex = file:find("%./") + if (findex == 1) then file = file:sub(3) end - file = debugger_convertParentDir(file) + file = debugger_convertParentDir(file) local fileLength = string.len(file) local suffixNames = { ".lua", @@ -886,8 +889,8 @@ local function debugger_getFilePathInfo(file) end local fileNameStartIndex = debugger_lastIndex(file, "/") if (fileNameStartIndex) then - fileName = string.sub(file, fileNameStartIndex + 1) - + fileName = string.sub(file, fileNameStartIndex + 1) + dir = string.sub(file, 1, fileNameStartIndex) file = dir .. fileName else @@ -898,12 +901,12 @@ local function debugger_getFilePathInfo(file) else dir = string.sub(file, 1, fileNameStartIndex) dir = dir:gsub("%.", "/") - fileName = string.sub(file, fileNameStartIndex + 1) - file = dir .. fileName + fileName = string.sub(file, fileNameStartIndex + 1) + file = dir .. fileName end - end + end - return file, dir, fileName + return file, dir, fileName end --@endregion @@ -915,25 +918,25 @@ end local function debugger_strSplit(input, delimiter) - input = tostring(input) - delimiter = tostring(delimiter) - if (delimiter == "") then + input = tostring(input) + delimiter = tostring(delimiter) + if (delimiter == "") then return false end - local pos, arr = 0, {} - -- for each divider found - for st, sp in function() + local pos, arr = 0, {} + -- for each divider found + for st, sp in function() return string.find(input, delimiter, pos, true) - end do - table.insert(arr, string.sub(input, pos, st - 1)) - pos = sp + 1 - end - table.insert(arr, string.sub(input, pos)) - return arr + end do + table.insert(arr, string.sub(input, pos, st - 1)) + pos = sp + 1 + end + table.insert(arr, string.sub(input, pos)) + return arr end local function debugger_strTrim(input) - input = string.gsub(input, "^[ \t\n\r]+", "") - return string.gsub(input, "[ \t\n\r]+$", "") + input = string.gsub(input, "^[ \t\n\r]+", "") + return string.gsub(input, "[ \t\n\r]+$", "") end local function debugger_dump(value, desciption, nesting) if type(nesting) ~= "number" then @@ -948,7 +951,7 @@ local function debugger_dump(value, desciption, nesting) return tostring(v) end local traceback = debugger_strSplit(debug.traceback("", 2), "\n") - print("dump from: " .. debugger_strTrim(traceback[3])) + -- print("dump from: " .. debugger_strTrim(traceback[3])) local function _dump(value, desciption, indent, nest, keylen) desciption = desciption or "" local spc = "" @@ -997,7 +1000,7 @@ local function debugger_dump(value, desciption, nesting) end _dump(value, desciption, "- ", 1) for i, line in ipairs(result) do - print(line) + -- print(line) end end --@endregion @@ -1005,27 +1008,24 @@ local function debugger_valueToString(v) local vtype = type(v) local vstr = nil if (vtype == "userdata") then - if (LuaDebugger.isFoxGloryProject ) then - - return "userdata",vtype - + if (LuaDebugger.isFoxGloryProject) then + return "userdata", vtype else return tostring(v), vtype end elseif (vtype == "table" or vtype == "function" or vtype == "boolean") then local value = vtype - xpcall(function() - if(LuaDebugger.isFoxGloryProject) then + xpcall(function() + if (LuaDebugger.isFoxGloryProject) then value = vtype else value = tostring(v) end - - end,function() + end, function() value = vtype end) return value, vtype - elseif (vtype == "number" or vtype == "string" ) then + elseif (vtype == "number" or vtype == "string") then return v, vtype else return tostring(v), vtype @@ -1033,12 +1033,12 @@ local function debugger_valueToString(v) end local function debugger_setVarInfo(name, value) local valueStr, valueType = debugger_valueToString(value) - local nameStr,nameType = debugger_valueToString(name) - if(valueStr == nil) then + local nameStr, nameType = debugger_valueToString(name) + if (valueStr == nil) then valueStr = valueType end local valueInfo = { - name =nameStr, + name = nameStr, valueType = valueType, valueStr = ZZBase64.encode(valueStr) } @@ -1047,283 +1047,282 @@ local function debugger_setVarInfo(name, value) end local function debugger_getvalue(f) - local i = 1 - local locals = {} - -- get locals - while true do - local name, value = debug.getlocal(f, i) - if not name then + local i = 1 + local locals = {} + -- get locals + while true do + local name, value = debug.getlocal(f, i) + if not name then break end if (name ~= "(*temporary)") then - locals[name] = value - end - i = i + 1 - end - local func = getinfo(f, "f").func - i = 1 - local ups = {} - while func do -- check for func as it may be nil for tail calls - local name, value = debug.getupvalue(func, i) - if not name then + locals[name] = value + end + i = i + 1 + end + local func = getinfo(f, "f").func + i = 1 + local ups = {} + while func do -- check for func as it may be nil for tail calls + local name, value = debug.getupvalue(func, i) + if not name then break end if (name == "_ENV") then - ups["_ENV_"] = value - else - ups[name] = value - end - i = i + 1 - end + ups["_ENV_"] = value + else + ups[name] = value + end + i = i + 1 + end - return {locals = locals, ups = ups} + return { locals = locals, ups = ups } end --获取堆栈 debugger_stackInfo = function(ignoreCount, event) - local datas = {} - local stack = {} - local varInfos = {} - local funcs = {} - local index = 0 - for i = ignoreCount, 100 do - local source = getinfo(i) - local isadd = true - if (i == ignoreCount) then - local file = source.source - if (file:find(LuaDebugger.DebugLuaFie)) then - return - end - if (file == "=[C]") then - isadd = false - end - end - if not source then - break - end - if (isadd) then - local fullName, dir, fileName = debugger_getFilePathInfo(source.source) - local info = { - src = fullName, - scoreName = source.name, - currentline = source.currentline, - linedefined = source.linedefined, - what = source.what, - nameWhat = source.namewhat - } - index = i - local vars = debugger_getvalue(i + 1) - table.insert(stack, info) - table.insert(varInfos, vars) - table.insert(funcs, source.func) - end - if source.what == "main" then - break + local datas = {} + local stack = {} + local varInfos = {} + local funcs = {} + local index = 0 + for i = ignoreCount, 100 do + local source = getinfo(i) + local isadd = true + if (i == ignoreCount) then + local file = source.source + if (file:find(LuaDebugger.DebugLuaFie)) then + return + end + if (file == "=[C]") then + isadd = false + end + end + if not source then + break + end + if (isadd) then + local fullName, dir, fileName = debugger_getFilePathInfo(source.source) + local info = { + src = fullName, + scoreName = source.name, + currentline = source.currentline, + linedefined = source.linedefined, + what = source.what, + nameWhat = source.namewhat + } + index = i + local vars = debugger_getvalue(i + 1) + table.insert(stack, info) + table.insert(varInfos, vars) + table.insert(funcs, source.func) + end + if source.what == "main" then + break + end end - end - local stackInfo = {stack = stack, vars = varInfos, funcs = funcs} - local data = { - stack = stackInfo.stack, - vars = stackInfo.vars, - funcs = stackInfo.funcs, - event = event, - funcsLength = #stackInfo.funcs, - upFunc = getinfo(ignoreCount - 3, "f").func - } + local stackInfo = { stack = stack, vars = varInfos, funcs = funcs } + local data = { + stack = stackInfo.stack, + vars = stackInfo.vars, + funcs = stackInfo.funcs, + event = event, + funcsLength = #stackInfo.funcs, + upFunc = getinfo(ignoreCount - 3, "f").func + } - return data -end + return data + end --==============================工具方法 end====================================================== --===========================点断信息================================================== --根据不同的游戏引擎进行定时获取断点信息 --CCDirector:sharedDirector():getScheduler() local debugger_setBreak = nil local function debugger_receiveDebugBreakInfo() - if(not jit) then - if(_VERSION)then - print("当前lua版本为: ".._VERSION.." 请使用 -----LuaDebug.lua----- 进行调试!") - else - print("当前为lua版本,请使用-----LuaDebug.lua-----进行调试!") - end - end - if (breakInfoSocket) then + if (not jit) then + if (_VERSION) then + -- print("当前lua版本为: ".._VERSION.." 请使用 -----LuaDebug.lua----- 进行调试!") + else + -- print("当前为lua版本,请使用-----LuaDebug.lua-----进行调试!") + end + end + if (breakInfoSocket) then local msg, status = breakInfoSocket:receive() - if(LuaDebugger.isLaunch == true and status == "closed") then + if (LuaDebugger.isLaunch == true and status == "closed") then os.exit() end - if (msg) then - local netData = json.decode(msg) - if netData.event == LuaDebugger.event.S2C_SetBreakPoints then - debugger_setBreak(netData.data) - elseif netData.event == LuaDebugger.event.S2C_LoadLuaScript then - LuaDebugger.loadScriptBody = netData.data + if (msg) then + local netData = json.decode(msg) + if netData.event == LuaDebugger.event.S2C_SetBreakPoints then + debugger_setBreak(netData.data) + elseif netData.event == LuaDebugger.event.S2C_LoadLuaScript then + LuaDebugger.loadScriptBody = netData.data debugger_exeLuaString() - debugger_sendMsg(breakInfoSocket,LuaDebugger.event.C2S_LoadLuaScript,LuaDebugger.loadScriptBody) + debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) elseif netData.event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.reLoadFileBody = netData.data LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) LuaDebugger.reLoadFileBody.script = nil - + debugger_sendMsg( breakInfoSocket, LuaDebugger.event.C2S_ReLoadFile, { stack = LuaDebugger.reLoadFileBody - + } - ) - end - end - end + ) + end + end + end end local function splitFilePath(path) - if (LuaDebugger.splitFilePaths[path]) then - return LuaDebugger.splitFilePaths[path] - end - local pos, arr = 0, {} - -- for each divider found - for st, sp in function() + if (LuaDebugger.splitFilePaths[path]) then + return LuaDebugger.splitFilePaths[path] + end + local pos, arr = 0, {} + -- for each divider found + for st, sp in function() return string.find(path, "/", pos, true) - end do - local pathStr = string.sub(path, pos, st - 1) - table.insert(arr, pathStr) - pos = sp + 1 - end - local pathStr = string.sub(path, pos) - table.insert(arr, pathStr) - LuaDebugger.splitFilePaths[path] = arr - return arr -end -debugger_setBreak = - function(datas) - local breakInfos = LuaDebugger.breakInfos - for i, data in ipairs(datas) do - data.fileName = string.lower(data.fileName) - data.serverPath = string.lower(data.serverPath) - local breakInfo = breakInfos[data.fileName] - if (not breakInfo) then - breakInfos[data.fileName] = {} - breakInfo = breakInfos[data.fileName] - end - if (not data.breakDatas or #data.breakDatas == 0) then - breakInfo[data.serverPath] = nil - else - local fileBreakInfo = breakInfo[data.serverPath] - if (not fileBreakInfo) then - fileBreakInfo = { - pathNames = splitFilePath(data.serverPath), - --命中次數判斷計數器 - hitCounts = {} - } - breakInfo[data.serverPath] = fileBreakInfo - end - local lineInfos = {} - for li, breakData in ipairs(data.breakDatas) do - lineInfos[breakData.line] = breakData - if (breakData.hitCondition and breakData.hitCondition ~= "") then - breakData.hitCondition = tonumber(breakData.hitCondition) - else - breakData.hitCondition = 0 - end - if (not fileBreakInfo.hitCounts[breakData.line]) then - fileBreakInfo.hitCounts[breakData.line] = 0 - end - end - fileBreakInfo.lines = lineInfos - --這裡添加命中次數判斷 - for line, count in pairs(fileBreakInfo.hitCounts) do - if (not lineInfos[line]) then - fileBreakInfo.hitCounts[line] = nil - end - end - end - local count = 0 - for i, linesInfo in pairs(breakInfo) do - count = count + 1 - end - if (count == 0) then - breakInfos[data.fileName] = nil - end - end - --debugger_dump(breakInfos, "breakInfos", 6) - --检查是否需要断点 - local isHook = false - for k, v in pairs(breakInfos) do - isHook = true - break - end - - --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 - if (isHook) then - if (not LuaDebugger.isHook) then - debug.sethook(debug_hook, "lrc") - end - LuaDebugger.isHook = true - else - if (LuaDebugger.isHook) then - debug.sethook() - end - LuaDebugger.isHook = false - end + end do + local pathStr = string.sub(path, pos, st - 1) + table.insert(arr, pathStr) + pos = sp + 1 + end + local pathStr = string.sub(path, pos) + table.insert(arr, pathStr) + LuaDebugger.splitFilePaths[path] = arr + return arr end +debugger_setBreak = + function(datas) + local breakInfos = LuaDebugger.breakInfos + for i, data in ipairs(datas) do + data.fileName = string.lower(data.fileName) + data.serverPath = string.lower(data.serverPath) + local breakInfo = breakInfos[data.fileName] + if (not breakInfo) then + breakInfos[data.fileName] = {} + breakInfo = breakInfos[data.fileName] + end + if (not data.breakDatas or #data.breakDatas == 0) then + breakInfo[data.serverPath] = nil + else + local fileBreakInfo = breakInfo[data.serverPath] + if (not fileBreakInfo) then + fileBreakInfo = { + pathNames = splitFilePath(data.serverPath), + --命中次數判斷計數器 + hitCounts = {} + } + breakInfo[data.serverPath] = fileBreakInfo + end + local lineInfos = {} + for li, breakData in ipairs(data.breakDatas) do + lineInfos[breakData.line] = breakData + if (breakData.hitCondition and breakData.hitCondition ~= "") then + breakData.hitCondition = tonumber(breakData.hitCondition) + else + breakData.hitCondition = 0 + end + if (not fileBreakInfo.hitCounts[breakData.line]) then + fileBreakInfo.hitCounts[breakData.line] = 0 + end + end + fileBreakInfo.lines = lineInfos + --這裡添加命中次數判斷 + for line, count in pairs(fileBreakInfo.hitCounts) do + if (not lineInfos[line]) then + fileBreakInfo.hitCounts[line] = nil + end + end + end + local count = 0 + for i, linesInfo in pairs(breakInfo) do + count = count + 1 + end + if (count == 0) then + breakInfos[data.fileName] = nil + end + end + --debugger_dump(breakInfos, "breakInfos", 6) + --检查是否需要断点 + local isHook = false + for k, v in pairs(breakInfos) do + isHook = true + break + end + + --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 + if (isHook) then + if (not LuaDebugger.isHook) then + debug.sethook(debug_hook, "lrc") + end + LuaDebugger.isHook = true + else + if (LuaDebugger.isHook) then + debug.sethook() + end + LuaDebugger.isHook = false + end + end local function debugger_checkFileIsBreak(fileName) - return LuaDebugger.breakInfos[fileName] + return LuaDebugger.breakInfos[fileName] end --=====================================断点信息 end ---------------------------------------------- local controller_host = "192.168.1.102" local controller_port = 7003 debugger_sendMsg = function(serverSocket, eventName, data) - local sendMsg = { - event = eventName, - data = data - } - local sendStr = json.encode(sendMsg) - serverSocket:send(sendStr .. "__debugger_k0204__") + local sendMsg = { + event = eventName, + data = data + } + local sendStr = json.encode(sendMsg) + serverSocket:send(sendStr .. "__debugger_k0204__") end -function debugger_conditionStr(condition, vars, callBack) - local function loadScript() - local currentTabble = {} - - local locals = vars[1].locals - local ups = vars[1].ups - if (ups) then - for k, v in pairs(ups) do - currentTabble[k] = v - end - end - - if (locals) then - for k, v in pairs(locals) do - currentTabble[k] = v - end - end - setmetatable(currentTabble, {__index = _G}) - local fun = loadstring("return " .. condition) - setfenv(fun, currentTabble) - return fun() - end - local status, - msg = - xpcall( - loadScript, - function(error) - print(error) +function debugger_conditionStr(condition, vars, callBack) + local function loadScript() + local currentTabble = {} + + local locals = vars[1].locals + local ups = vars[1].ups + if (ups) then + for k, v in pairs(ups) do + currentTabble[k] = v + end end - ) + + if (locals) then + for k, v in pairs(locals) do + currentTabble[k] = v + end + end + setmetatable(currentTabble, { __index = _G }) + local fun = loadstring("return " .. condition) + setfenv(fun, currentTabble) + return fun() + end + local status, + msg = + xpcall( + loadScript, + function(error) + -- print(error) + end + ) if (status and msg) then callBack() end end + --执行lua字符串 debugger_exeLuaString = function() - local function loadScript() - local script = LuaDebugger.loadScriptBody.script if (LuaDebugger.loadScriptBody.isBreak) then - local currentTabble = {_G = _G} + local currentTabble = { _G = _G } local frameId = LuaDebugger.loadScriptBody.frameId frameId = frameId local func = LuaDebugger.currentDebuggerData.funcs[frameId] @@ -1336,8 +1335,8 @@ debugger_exeLuaString = function() for k, v in pairs(locals) do currentTabble[k] = v end - setmetatable(currentTabble, {__index = _G}) - + setmetatable(currentTabble, { __index = _G }) + local fun = loadstring(script) setfenv(fun, currentTabble) fun() @@ -1347,54 +1346,51 @@ debugger_exeLuaString = function() end end local status, - msg = + msg = xpcall( - loadScript, - function(error) - - -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) - end - ) - LuaDebugger.loadScriptBody.script = nil + loadScript, + function(error) + -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) + end + ) + LuaDebugger.loadScriptBody.script = nil if (LuaDebugger.loadScriptBody.isBreak) then - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack - end + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event + .C2S_HITBreakPoint) + LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack + end LuaDebugger.loadScriptBody.complete = true - end --@region 调试中修改变量值 --根据key 值在 value 查找 -local function debugger_getTablekey(key,keyType,value) - if(keyType == -1) then +local function debugger_getTablekey(key, keyType, value) + if (keyType == -1) then return key - elseif(keyType == 1) then + elseif (keyType == 1) then return tonumber(key) - elseif(keyType == 2) then + elseif (keyType == 2) then local valueKey = nil - for k,v in pairs(value) do + for k, v in pairs(value) do local nameType = type(k) - if(nameType == "userdata" or nameType == "table") then + if (nameType == "userdata" or nameType == "table") then if (not LuaDebugger.isFoxGloryProject) then valueKey = tostring(k) - if(key == valueKey) then + if (key == valueKey) then return k end break end end end - end end local function debugger_setVarValue(server, data) - local newValue = nil - local level = LuaDebugger.serVarLevel+LuaDebugger.setVarBody.frameId + local level = LuaDebugger.serVarLevel + LuaDebugger.setVarBody.frameId local firstKeyName = data.keys[1] --@region vars check local localValueChangeIndex = -1 @@ -1409,7 +1405,7 @@ local function debugger_setVarValue(server, data) if not name then break end - if(firstKeyName == name) then + if (firstKeyName == name) then localValueChangeIndex = i oldValue = value end @@ -1423,11 +1419,11 @@ local function debugger_setVarValue(server, data) local ups = {} while func do -- check for func as it may be nil for tail calls local name, value = debug.getupvalue(func, i) - + if not name then break end - if(localValueChangeIndex == -1 and firstKeyName == name) then + if (localValueChangeIndex == -1 and firstKeyName == name) then upValueFun = func oldValue = value upValueChangeIndex = i @@ -1439,9 +1435,9 @@ local function debugger_setVarValue(server, data) end i = i + 1 end ---@endregion - local vars = {locals = locals, ups = ups} - + --@endregion + local vars = { locals = locals, ups = ups } + local function loadScript() local currentTabble = {} local locals = vars.locals @@ -1457,58 +1453,56 @@ local function debugger_setVarValue(server, data) currentTabble[k] = v end end - setmetatable(currentTabble, {__index = _G}) + setmetatable(currentTabble, { __index = _G }) local fun = loadstring("return " .. data.value) setfenv(fun, currentTabble) newValue = fun() end local status, - msg = + msg = xpcall( - loadScript, - function(error) - print(error, "============================") - end - ) - + loadScript, + function(error) + -- print(error, "============================") + end + ) + local i = 1 - + -- local 查找并替换 local keyLength = #data.keys - - if(keyLength == 1) then - if(localValueChangeIndex ~= -1) then - + + if (keyLength == 1) then + if (localValueChangeIndex ~= -1) then debug.setlocal(level, localValueChangeIndex, newValue) - elseif(upValueFun ~= nil) then - debug.setupvalue( upValueFun, upValueChangeIndex, newValue ) + elseif (upValueFun ~= nil) then + debug.setupvalue(upValueFun, upValueChangeIndex, newValue) else --全局变量查找 - if(_G[firstKeyName]) then + if (_G[firstKeyName]) then _G[firstKeyName] = newValue end end else - if(not oldValue) then - if(_G[firstKeyName]) then + if (not oldValue) then + if (_G[firstKeyName]) then oldValue = _G[firstKeyName] end end local tempValue = oldValue - for i=2,keyLength-1 do - if(tempValue) then - oldValue = oldValue[debugger_getTablekey(data.keys[i],data.numberTypes[i],oldValue)] + for i = 2, keyLength - 1 do + if (tempValue) then + oldValue = oldValue[debugger_getTablekey(data.keys[i], data.numberTypes[i], oldValue)] end end - if(tempValue) then - oldValue[debugger_getTablekey(data.keys[keyLength],data.numberTypes[keyLength],oldValue)] = newValue + if (tempValue) then + oldValue[debugger_getTablekey(data.keys[keyLength], data.numberTypes[keyLength], oldValue)] = newValue end end - local varInfo = debugger_setVarInfo(data.varName, newValue) + local varInfo = debugger_setVarInfo(data.varName, newValue) data.varInfo = varInfo - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - end --@endregion @@ -1518,107 +1512,107 @@ end --调试修改变量值统一的 _resume checkSetVar = function() - if (LuaDebugger.isSetVar) then - LuaDebugger.isSetVar = false - debugger_setVarValue(debug_server,LuaDebugger.setVarBody) - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.setVarBody) - xpcall( - checkSetVar, - function(error) - print("设置变量", error) - end - ) - elseif(LuaDebugger.isLoadLuaScript) then - LuaDebugger.isLoadLuaScript = false - debugger_exeLuaString() - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("执行代码", error) - end - ) - elseif(LuaDebugger.isReLoadFile) then - LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) - print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) - LuaDebugger.reLoadFileBody.script = nil - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("重新加载文件", error) - end - ) + if (LuaDebugger.isSetVar) then + LuaDebugger.isSetVar = false + debugger_setVarValue(debug_server, LuaDebugger.setVarBody) + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.setVarBody) + xpcall( + checkSetVar, + function(error) + -- print("设置变量", error) + end + ) + elseif (LuaDebugger.isLoadLuaScript) then + LuaDebugger.isLoadLuaScript = false + debugger_exeLuaString() + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("执行代码", error) + end + ) + elseif (LuaDebugger.isReLoadFile) then + LuaDebugger.isReLoadFile = false + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + -- print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.script = nil + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("重新加载文件", error) + end + ) + end end -end - + local function getSource(source) - source = string.lower(source) + source = string.lower(source) if (LuaDebugger.pathCachePaths[source]) then - LuaDebugger.currentLineFile = LuaDebugger.pathCachePaths[source] - return LuaDebugger.pathCachePaths[source] - end + LuaDebugger.currentLineFile = LuaDebugger.pathCachePaths[source] + return LuaDebugger.pathCachePaths[source] + end - local fullName, dir, fileName = debugger_getFilePathInfo(source) - LuaDebugger.currentLineFile = fullName - LuaDebugger.pathCachePaths[source] = fileName + local fullName, dir, fileName = debugger_getFilePathInfo(source) + LuaDebugger.currentLineFile = fullName + LuaDebugger.pathCachePaths[source] = fileName - return fileName + return fileName end local function debugger_GeVarInfoBytUserData(server, var) - local fileds = LuaDebugTool.getUserDataInfo(var) - - local varInfos = {} + local fileds = LuaDebugTool.getUserDataInfo(var) - - --c# vars - for i = 1, fileds.Count do - local filed = fileds[i - 1] - local valueInfo = { - name = filed.name, - valueType = filed.valueType, - valueStr = ZZBase64.encode(filed.valueStr), - isValue = filed.isValue, - csharp = true - } - - table.insert(varInfos, valueInfo) - end - return varInfos -end + local varInfos = {} + + + --c# vars + for i = 1, fileds.Count do + local filed = fileds[i - 1] + local valueInfo = { + name = filed.name, + valueType = filed.valueType, + valueStr = ZZBase64.encode(filed.valueStr), + isValue = filed.isValue, + csharp = true + } + + table.insert(varInfos, valueInfo) + end + return varInfos +end local function debugger_getValueByScript(value, script) - local val = nil - local status, - msg = - xpcall( - function() - local fun = loadstring("return " .. script) - setfenv(fun, value) - val = fun() - end, - function(error) - print(error, "====>") - val = nil - end - ) + local val = nil + local status, + msg = + xpcall( + function() + local fun = loadstring("return " .. script) + setfenv(fun, value) + val = fun() + end, + function(error) + -- print(error, "====>") + val = nil + end + ) - return val + return val end -local function debugger_getVarByKeys(value, keys, index) - local str = "" - local keyLength = #keys - for i = index, keyLength do - local key = keys[i] - if (key == "[metatable]") then - else - if (i == index) then +local function debugger_getVarByKeys(value, keys, index) + local str = "" + local keyLength = #keys + for i = index, keyLength do + local key = keys[i] + if (key == "[metatable]") then + else + if (i == index) then if (string.find(key, "%.")) then if (str == "") then i = index + 1 @@ -1630,10 +1624,10 @@ local function debugger_getVarByKeys(value, keys, index) return debugger_getVarByKeys(value, keys, i) else - str = key - end - else - if (string.find(key, "%[")) then + str = key + end + else + if (string.find(key, "%[")) then str = str .. key elseif (type(key) == "string") then if (string.find(key, "table:") or string.find(key, "userdata:") or string.find(key, "function:")) then @@ -1712,7 +1706,7 @@ end local function debugger_searchVarByKeys(value, keys, searckKeys) local index, val = debugger_getVarByKeys(value, searckKeys, 1) - if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then + if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then return index, val end if (val) then @@ -1745,7 +1739,6 @@ end return ]] local function debugger_getmetatable(value, metatable, vinfos, server, variablesReference, debugSpeedIndex, metatables) - for i, mtable in ipairs(metatables) do if (metatable == mtable) then return vinfos @@ -1794,14 +1787,13 @@ local function debugger_getmetatable(value, metatable, vinfos, server, variables end end end - + local m = getmetatable(metatable) if (m) then return debugger_getmetatable(value, m, vinfos, server, variablesReference, debugSpeedIndex, metatables) else return vinfos end - end local function debugger_sendTableField(luatable, vinfos, server, variablesReference, debugSpeedIndex, valueType) if (valueType == "userdata") then @@ -1840,12 +1832,12 @@ local function debugger_sendTableValues(value, server, variablesReference, debug local valueType = type(value) local userDataInfos = {} local m = nil - + if (valueType == "userdata") then m = getmetatable(value) - + vinfos = debugger_sendTableField(value, vinfos, server, variablesReference, debugSpeedIndex, valueType) - + if (LuaDebugTool) then local varInfos = debugger_GeVarInfoBytUserData(server, value, variablesReference, debugSpeedIndex) @@ -1874,7 +1866,6 @@ local function debugger_sendTableValues(value, server, variablesReference, debug vinfos = {} end end - end else m = getmetatable(value) @@ -1898,56 +1889,55 @@ end --获取lua 变量的方法 local function debugger_getBreakVar(body, server) - local variablesReference = body.variablesReference - local debugSpeedIndex = body.debugSpeedIndex - local vinfos = {} - local function exe() - local frameId = body.frameId + local variablesReference = body.variablesReference + local debugSpeedIndex = body.debugSpeedIndex + local vinfos = {} + local function exe() + local frameId = body.frameId local type_ = body.type local keys = body.keys - --找到对应的var - local vars = nil - if (type_ == 1) then - vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] - vars = vars.locals - elseif (type_ == 2) then - vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] - vars = vars.ups - elseif (type_ == 3) then - vars = _G - end - if (#keys == 0) then - debugger_sendTableValues(vars, server, variablesReference, debugSpeedIndex) - return - end - local index, value = debugger_searchVarByKeys(vars, keys, keys) - if (value) then - local valueType = type(value) + --找到对应的var + local vars = nil + if (type_ == 1) then + vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] + vars = vars.locals + elseif (type_ == 2) then + vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] + vars = vars.ups + elseif (type_ == 3) then + vars = _G + end + if (#keys == 0) then + debugger_sendTableValues(vars, server, variablesReference, debugSpeedIndex) + return + end + local index, value = debugger_searchVarByKeys(vars, keys, keys) + if (value) then + local valueType = type(value) if (valueType == "table" or valueType == "userdata") then - - debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) - else + debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) + else if (valueType == "function") then - if(LuaDebugger.isFoxGloryProject) then - value = "function" + if (LuaDebugger.isFoxGloryProject) then + value = "function" else value = tostring(value) end - end - debugger_sendMsg( + end + debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, { - variablesReference = variablesReference, - debugSpeedIndex = debugSpeedIndex, - vars = ZZBase64.encode(value), - isComplete = 1, - varType = valueType - } + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = ZZBase64.encode(value), + isComplete = 1, + varType = valueType + } ) - end - else - debugger_sendMsg( + end + else + debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, { @@ -1958,14 +1948,14 @@ local function debugger_getBreakVar(body, server) varType = "nil" } ) - end - end - xpcall( + end + end + xpcall( exe, function(error) - -- print("获取变量错误 错误消息-----------------") - -- print(error) - -- print(debug.traceback("", 2)) + -- -- print("获取变量错误 错误消息-----------------") + -- -- print(error) + -- -- print(debug.traceback("", 2)) debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, @@ -1987,64 +1977,62 @@ local function debugger_getBreakVar(body, server) ) end local function ResetDebugInfo() - LuaDebugger.Run = false - LuaDebugger.StepIn = false - LuaDebugger.StepNext = false - LuaDebugger.StepOut = false - + LuaDebugger.Run = false + LuaDebugger.StepIn = false + LuaDebugger.StepNext = false + LuaDebugger.StepOut = false end local function debugger_loop(server) - server = debug_server - --命令 - local command - local eval_env = {} - local arg - while true do - local line, status = server:receive() - if (status == "closed") then - if(LuaDebugger.isLaunch) then + server = debug_server + --命令 + local command + local eval_env = {} + local arg + while true do + local line, status = server:receive() + if (status == "closed") then + if (LuaDebugger.isLaunch) then os.exit() else debug.sethook() coroutine.yield() end - end - if (line) then - local netData = json.decode(line) - local event = netData.event + end + if (line) then + local netData = json.decode(line) + local event = netData.event local body = netData.data if (event == LuaDebugger.event.S2C_DebugClose) then - if(LuaDebugger.isLaunch) then - os.exit() - else - debug.sethook() - coroutine.yield() - end - - elseif event == LuaDebugger.event.S2C_SetBreakPoints then - --设置断点信息 - local function setB() - debugger_setBreak(body) - end - xpcall( + if (LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end + elseif event == LuaDebugger.event.S2C_SetBreakPoints then + --设置断点信息 + local function setB() + debugger_setBreak(body) + end + xpcall( setB, function(error) - print(error) + -- print(error) end ) - elseif event == LuaDebugger.event.S2C_RUN then --开始运行 - LuaDebugger.runTimeType = body.runTimeType - LuaDebugger.isProntToConsole = body.isProntToConsole + elseif event == LuaDebugger.event.S2C_RUN then --开始运行 + LuaDebugger.runTimeType = body.runTimeType + LuaDebugger.isProntToConsole = body.isProntToConsole LuaDebugger.isFoxGloryProject = body.isFoxGloryProject LuaDebugger.isLaunch = body.isLaunch - ResetDebugInfo() - LuaDebugger.currentDebuggerData = nil - LuaDebugger.Run = true + ResetDebugInfo() + LuaDebugger.currentDebuggerData = nil + LuaDebugger.Run = true LuaDebugger.tempRunFlag = true - LuaDebugger.currentLine= nil - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - LuaDebugger.currentDebuggerData = data + LuaDebugger.currentLine = nil + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + LuaDebugger.currentDebuggerData = data debugger_sendMsg( server, data.event, @@ -2052,58 +2040,58 @@ local function debugger_loop(server) stack = data.stack } ) - elseif event == LuaDebugger.event.S2C_ReqVar then -- 获取变量信息 - --请求数据信息 - debugger_getBreakVar(body, server) - elseif event == LuaDebugger.event.S2C_NextRequest then -- 设置单步跳过 - ResetDebugInfo() - LuaDebugger.StepNext = true - --设置当前文件名和当前行数 - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - --重置调试信息 - LuaDebugger.currentDebuggerData = data - debugger_sendMsg( + elseif event == LuaDebugger.event.S2C_ReqVar then -- 获取变量信息 + --请求数据信息 + debugger_getBreakVar(body, server) + elseif event == LuaDebugger.event.S2C_NextRequest then -- 设置单步跳过 + ResetDebugInfo() + LuaDebugger.StepNext = true + --设置当前文件名和当前行数 + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( server, data.event, { stack = data.stack } ) - elseif (event == LuaDebugger.event.S2C_StepInRequest) then --单步跳入 - --单步跳入 - ResetDebugInfo() - LuaDebugger.StepIn = true - - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - --重置调试信息 - LuaDebugger.currentDebuggerData = data - debugger_sendMsg( + elseif (event == LuaDebugger.event.S2C_StepInRequest) then --单步跳入 + --单步跳入 + ResetDebugInfo() + LuaDebugger.StepIn = true + + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( server, data.event, { - stack = data.stack, - eventType = data.eventType - } - ) - elseif (event == LuaDebugger.event.S2C_StepOutRequest) then - --单步跳出 - ResetDebugInfo() - LuaDebugger.StepOut = true - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - --重置调试信息 - LuaDebugger.currentDebuggerData = data - debugger_sendMsg( + stack = data.stack, + eventType = data.eventType + } + ) + elseif (event == LuaDebugger.event.S2C_StepOutRequest) then + --单步跳出 + ResetDebugInfo() + LuaDebugger.StepOut = true + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( server, data.event, { - stack = data.stack, - eventType = data.eventType - } - ) - elseif event == LuaDebugger.event.S2C_LoadLuaScript then + stack = data.stack, + eventType = data.eventType + } + ) + elseif event == LuaDebugger.event.S2C_LoadLuaScript then LuaDebugger.loadScriptBody = body LuaDebugger.isLoadLuaScript = true local data = coroutine.yield() @@ -2123,8 +2111,8 @@ local function debugger_loop(server) stack = data, eventType = data.eventType } - ) - elseif event == LuaDebugger.event.S2C_ReLoadFile then + ) + elseif event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.isReLoadFile = true LuaDebugger.reLoadFileBody = body local data = coroutine.yield() @@ -2135,340 +2123,321 @@ local function debugger_loop(server) stack = data, eventType = data.eventType } - ) - end - end - end + ) + end + end + end end coro_debugger = coroutine.create(debugger_loop) debug_hook = function(event, line) + if (not LuaDebugger.isHook) then + return + end - if(not LuaDebugger.isHook) then - return - end + if (LuaDebugger.Run) then + if (event == "line") then + local isCheck = false + for k, breakInfo in pairs(LuaDebugger.breakInfos) do + for bk, linesInfo in pairs(breakInfo) do + if (linesInfo.lines and linesInfo.lines[line]) then + isCheck = true + break + end + end + if (isCheck) then + break + end + end - if(LuaDebugger.Run) then - if(event == "line") then - local isCheck = false - for k, breakInfo in pairs(LuaDebugger.breakInfos) do + if (not isCheck) then + return + end + end + end - for bk, linesInfo in pairs(breakInfo) do - - if(linesInfo.lines and linesInfo.lines[line]) then - isCheck = true - break - end - end - if(isCheck) then - break - end - end - - if(not isCheck) then - return - end - - end - end - - - local file = nil - if(event == "line") then - - local funs = nil - local funlength =0 - if(LuaDebugger.currentDebuggerData) then - funs = LuaDebugger.currentDebuggerData.funcs - funlength = #funs - end - local stepInfo = getinfo(2) - local tempFunc = stepInfo.func - local source = stepInfo.source - file = getSource(source); - if(source == "=[C]" or source:find(LuaDebugger.DebugLuaFie)) then return end - if(funlength > 0 and funs[1] == tempFunc and LuaDebugger.currentLine ~= line) then - LuaDebugger.runLineCount = LuaDebugger.runLineCount+1 - end - local breakInfo = LuaDebugger.breakInfos[file] - local breakData = nil - local ischeck = false - if(breakInfo) then - - for k, lineInfo in pairs(breakInfo) do - local lines = lineInfo.lines - if(lines and lines[line]) then - ischeck = true - break - end - end - end - local isHit = false - if(ischeck) then - - --并且在断点中 - local info = stepInfo - local source = string.lower( info.source ) - local fullName,dir,fileName = debugger_getFilePathInfo(source) - local hitPathNames = splitFilePath(fullName) - - local hitCounts = {} - local debugHitCounts = nil - for k, lineInfo in pairs(breakInfo) do + local file = nil + if (event == "line") then + local funs = nil + local funlength = 0 + if (LuaDebugger.currentDebuggerData) then + funs = LuaDebugger.currentDebuggerData.funcs + funlength = #funs + end + local stepInfo = getinfo(2) + local tempFunc = stepInfo.func + local source = stepInfo.source + file = getSource(source); + if (source == "=[C]" or source:find(LuaDebugger.DebugLuaFie)) then return end + if (funlength > 0 and funs[1] == tempFunc and LuaDebugger.currentLine ~= line) then + LuaDebugger.runLineCount = LuaDebugger.runLineCount + 1 + end + local breakInfo = LuaDebugger.breakInfos[file] + local breakData = nil + local ischeck = false + if (breakInfo) then + for k, lineInfo in pairs(breakInfo) do local lines = lineInfo.lines - local pathNames = lineInfo.pathNames - debugHitCounts = lineInfo.hitCounts - if(lines and lines[line]) then - breakData = lines[line] - --判断路径 - hitCounts[k] = 0 - local hitPathNamesCount = #hitPathNames - local pathNamesCount = #pathNames - local checkCount = 0; - while(true) do - if (pathNames[pathNamesCount] ~= hitPathNames[hitPathNamesCount]) then - break - else - hitCounts[k] = hitCounts[k] + 1 - end - pathNamesCount = pathNamesCount - 1 - hitPathNamesCount = hitPathNamesCount - 1 - checkCount = checkCount+1 - if(pathNamesCount <= 0 or hitPathNamesCount <= 0) then - break - end - end - if(checkCount>0) then - break; - end - else - breakData = nil - end - end - if(breakData) then - local hitFieName = "" - local maxCount = 0 - for k, v in pairs(hitCounts) do - if(v > maxCount) then - maxCount = v - hitFieName = k; - end - end - local hitPathNamesLength = #hitPathNames - if (hitPathNamesLength == 1 or (hitPathNamesLength > 1 and maxCount > 1)) then - if(hitFieName ~= "") then + if (lines and lines[line]) then + ischeck = true + break + end + end + end + local isHit = false + if (ischeck) then + --并且在断点中 + local info = stepInfo + local source = string.lower(info.source) + local fullName, dir, fileName = debugger_getFilePathInfo(source) + local hitPathNames = splitFilePath(fullName) + local hitCounts = {} + local debugHitCounts = nil + for k, lineInfo in pairs(breakInfo) do + local lines = lineInfo.lines + local pathNames = lineInfo.pathNames + debugHitCounts = lineInfo.hitCounts + if (lines and lines[line]) then + breakData = lines[line] + --判断路径 + hitCounts[k] = 0 + local hitPathNamesCount = #hitPathNames + local pathNamesCount = #pathNames + local checkCount = 0; + while (true) do + if (pathNames[pathNamesCount] ~= hitPathNames[hitPathNamesCount]) then + break + else + hitCounts[k] = hitCounts[k] + 1 + end + pathNamesCount = pathNamesCount - 1 + hitPathNamesCount = hitPathNamesCount - 1 + checkCount = checkCount + 1 + if (pathNamesCount <= 0 or hitPathNamesCount <= 0) then + break + end + end + if (checkCount > 0) then + break; + end + else + breakData = nil + end + end + if (breakData) then + local hitFieName = "" + local maxCount = 0 + for k, v in pairs(hitCounts) do + if (v > maxCount) then + maxCount = v + hitFieName = k; + end + end + local hitPathNamesLength = #hitPathNames + if (hitPathNamesLength == 1 or (hitPathNamesLength > 1 and maxCount > 1)) then + if (hitFieName ~= "") then local hitCount = breakData.hitCondition - local clientHitCount = debugHitCounts[breakData.line] - clientHitCount = clientHitCount + 1 - debugHitCounts[breakData.line] = clientHitCount - if(funs and funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then - LuaDebugger.runLineCount = 0 - elseif(LuaDebugger.tempRunFlag and LuaDebugger.currentLine == line) then - LuaDebugger.runLineCount = 0 - LuaDebugger.tempRunFlag = nil - elseif(clientHitCount >= hitCount) then - isHit = true - end - - end - end - end - end - if(LuaDebugger.StepOut) then - if(funlength == 1) then - ResetDebugInfo(); - LuaDebugger.Run = true - return - else - if(funs[2] == tempFunc) then - local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) - -- print("StepIn 挂起") - --挂起等待调试器作出反应 + local clientHitCount = debugHitCounts[breakData.line] + clientHitCount = clientHitCount + 1 + debugHitCounts[breakData.line] = clientHitCount + if (funs and funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then + LuaDebugger.runLineCount = 0 + elseif (LuaDebugger.tempRunFlag and LuaDebugger.currentLine == line) then + LuaDebugger.runLineCount = 0 + LuaDebugger.tempRunFlag = nil + elseif (clientHitCount >= hitCount) then + isHit = true + end + end + end + end + end + if (LuaDebugger.StepOut) then + if (funlength == 1) then + ResetDebugInfo(); + LuaDebugger.Run = true + return + else + if (funs[2] == tempFunc) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) + -- -- print("StepIn 挂起") + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - return - end - end - end - - if(LuaDebugger.StepIn) then - if(funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then - return - end - local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) - -- print("StepIn 挂起") - --挂起等待调试器作出反应 + return + end + end + end + + if (LuaDebugger.StepIn) then + if (funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then + return + end + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) + -- -- print("StepIn 挂起") + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - return - end - - if(LuaDebugger.StepNext ) then - local isNext = false - if(funs) then - for i,f in ipairs(funs) do - if(tempFunc == f) then - if(LuaDebugger.currentLine == line) then - return - end - isNext =true - break; - end - end + return + end + + if (LuaDebugger.StepNext) then + local isNext = false + if (funs) then + for i, f in ipairs(funs) do + if (tempFunc == f) then + if (LuaDebugger.currentLine == line) then + return + end + isNext = true + break; + end + end else - - isNext =true - end - if(isNext) then - local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) - LuaDebugger.runLineCount = 0 - LuaDebugger.currentLine = line - --挂起等待调试器作出反应 + isNext = true + end + if (isNext) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) + LuaDebugger.runLineCount = 0 + LuaDebugger.currentLine = line + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - return - end - end - - local sevent = nil - + return + end + end - --断点判断 - if(isHit) then - + local sevent = nil - LuaDebugger.runLineCount = 0 - LuaDebugger.currentLine = line - sevent = LuaDebugger.event.C2S_HITBreakPoint - --调用 coro_debugger 并传入 参数 - local data = debugger_stackInfo(3, sevent) - --挂起等待调试器作出反应 - if(breakData and breakData.condition) then - debugger_conditionStr(breakData.condition,data.vars,function() + + --断点判断 + if (isHit) then + LuaDebugger.runLineCount = 0 + LuaDebugger.currentLine = line + sevent = LuaDebugger.event.C2S_HITBreakPoint + --调用 coro_debugger 并传入 参数 + local data = debugger_stackInfo(3, sevent) + --挂起等待调试器作出反应 + if (breakData and breakData.condition) then + debugger_conditionStr(breakData.condition, data.vars, function() _resume(coro_debugger, data) checkSetVar() - end) - else - --挂起等待调试器作出反应 + end) + else + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - end - end - end + end + end + end end local function debugger_xpcall() - --调用 coro_debugger 并传入 参数 + --调用 coro_debugger 并传入 参数 local data = debugger_stackInfo(4, LuaDebugger.event.C2S_HITBreakPoint) - if(data.stack and data.stack[1]) then - data.stack[1].isXpCall = true + if (data.stack and data.stack[1]) then + data.stack[1].isXpCall = true end - --挂起等待调试器作出反应 + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() end --调试开始 local function start() - - local socket = createSocket() - print(controller_host) - print(controller_port) - - local fullName,dirName,fileName = debugger_getFilePathInfo(getinfo(1).source) - LuaDebugger.DebugLuaFie = fileName - local server = socket.connect(controller_host, controller_port) - debug_server = server; - if server then - --创建breakInfo socket - socket = createSocket() - breakInfoSocket = socket.connect(controller_host, controller_port) - if(breakInfoSocket) then - breakInfoSocket:settimeout(0) - debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_SetSocketName, { - name = "breakPointSocket" - }) - - - debugger_sendMsg(server, LuaDebugger.event.C2S_SetSocketName, { - name = "mainSocket", - version = LuaDebugger.version + local socket = createSocket() + -- print(controller_host) + -- print(controller_port) - }) - xpcall(function() - sethook(debug_hook, "lrc") - end, function(error) - print("error:", error) - end) - if(not jit) then - if(_VERSION)then - print("当前lua版本为: ".._VERSION.." 请使用LuaDebug 进行调试!") - else - print("当前为lua版本,请使用LuaDebug 进行调试!") - end - - end - _resume(coro_debugger, server) - end - end + local fullName, dirName, fileName = debugger_getFilePathInfo(getinfo(1).source) + LuaDebugger.DebugLuaFie = fileName + local server = socket.connect(controller_host, controller_port) + debug_server = server; + if server then + --创建breakInfo socket + socket = createSocket() + breakInfoSocket = socket.connect(controller_host, controller_port) + if (breakInfoSocket) then + breakInfoSocket:settimeout(0) + debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_SetSocketName, { + name = "breakPointSocket" + }) + + + debugger_sendMsg(server, LuaDebugger.event.C2S_SetSocketName, { + name = "mainSocket", + version = LuaDebugger.version + + }) + xpcall(function() + sethook(debug_hook, "lrc") + end, function(error) + -- print("error:", error) + end) + if (not jit) then + if (_VERSION) then + -- print("当前lua版本为: ".._VERSION.." 请使用LuaDebug 进行调试!") + else + -- print("当前为lua版本,请使用LuaDebug 进行调试!") + end + end + _resume(coro_debugger, server) + end + end end function StartDebug(host, port) - - - if(not host) then - print("error host nil") - end - if(not port) then - print("error prot nil") - end - if(type(host) ~= "string") then - print("error host not string") - end - if(type(port) ~= "number") then - print("error host not number") - end - controller_host = host - controller_port = port - xpcall(start, function(error) - -- body - print(error) - end) - return debugger_receiveDebugBreakInfo, debugger_xpcall + if (not host) then + -- print("error host nil") + end + if (not port) then + -- print("error prot nil") + end + if (type(host) ~= "string") then + -- print("error host not string") + end + if (type(port) ~= "number") then + -- print("error host not number") + end + controller_host = host + controller_port = port + xpcall(start, function(error) + -- body + -- print(error) + end) + return debugger_receiveDebugBreakInfo, debugger_xpcall end - - --base64 local string = string ZZBase64.__code = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', - }; + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', +}; ZZBase64.__decode = {} -for k,v in pairs(ZZBase64.__code) do - ZZBase64.__decode[string.byte(v,1)] = k - 1 +for k, v in pairs(ZZBase64.__code) do + ZZBase64.__decode[string.byte(v, 1)] = k - 1 end function ZZBase64.encode(text) - local len = string.len(text) - local left = len % 3 - len = len - left - local res = {} - local index = 1 + local len = string.len(text) + local left = len % 3 + len = len - left + local res = {} + local index = 1 for i = 1, len, 3 do - local a = string.byte(text, i ) + local a = string.byte(text, i) local b = string.byte(text, i + 1) local c = string.byte(text, i + 2) -- num = a<<16 + b<<8 + c - local num = a * 65536 + b * 256 + c + local num = a * 65536 + b * 256 + c for j = 1, 4 do --tmp = num >> ((4 -j) * 6) - local tmp = math.floor(num / (2 ^ ((4-j) * 6))) + local tmp = math.floor(num / (2 ^ ((4 - j) * 6))) --curPos = tmp&0x3f local curPos = tmp % 64 + 1 res[index] = ZZBase64.__code[curPos] @@ -2479,52 +2448,52 @@ function ZZBase64.encode(text) if left == 1 then ZZBase64.__left1(res, index, text, len) elseif left == 2 then - ZZBase64.__left2(res, index, text, len) + ZZBase64.__left2(res, index, text, len) end return table.concat(res) end function ZZBase64.__left2(res, index, text, len) local num1 = string.byte(text, len + 1) - num1 = num1 * 1024 --lshift 10 + num1 = num1 * 1024 --lshift 10 local num2 = string.byte(text, len + 2) - num2 = num2 * 4 --lshift 2 + num2 = num2 * 4 --lshift 2 local num = num1 + num2 - + local tmp1 = math.floor(num / 4096) --rShift 12 local curPos = tmp1 % 64 + 1 res[index] = ZZBase64.__code[curPos] - + local tmp2 = math.floor(num / 64) curPos = tmp2 % 64 + 1 res[index + 1] = ZZBase64.__code[curPos] curPos = num % 64 + 1 res[index + 2] = ZZBase64.__code[curPos] - - res[index + 3] = "=" + + res[index + 3] = "=" end -function ZZBase64.__left1(res, index,text, len) +function ZZBase64.__left1(res, index, text, len) local num = string.byte(text, len + 1) - num = num * 16 - + num = num * 16 + local tmp = math.floor(num / 64) local curPos = tmp % 64 + 1 - res[index ] = ZZBase64.__code[curPos] - + res[index] = ZZBase64.__code[curPos] + curPos = num % 64 + 1 res[index + 1] = ZZBase64.__code[curPos] - - res[index + 2] = "=" - res[index + 3] = "=" + + res[index + 2] = "=" + res[index + 3] = "=" end function ZZBase64.decode(text) local len = string.len(text) - local left = 0 + local left = 0 if string.sub(text, len - 1) == "==" then - left = 2 + left = 2 len = len - 4 elseif string.sub(text, len) == "=" then left = 1 @@ -2534,20 +2503,20 @@ function ZZBase64.decode(text) local res = {} local index = 1 local decode = ZZBase64.__decode - for i =1, len, 4 do - local a = decode[string.byte(text,i )] - local b = decode[string.byte(text,i + 1)] - local c = decode[string.byte(text,i + 2)] - local d = decode[string.byte(text,i + 3)] + for i = 1, len, 4 do + local a = decode[string.byte(text, i)] + local b = decode[string.byte(text, i + 1)] + local c = decode[string.byte(text, i + 2)] + local d = decode[string.byte(text, i + 3)] --num = a<<18 + b<<12 + c<<6 + d local num = a * 262144 + b * 4096 + c * 64 + d - + local e = string.char(num % 256) num = math.floor(num / 256) local f = string.char(num % 256) num = math.floor(num / 256) - res[index ] = string.char(num % 256) + res[index] = string.char(num % 256) res[index + 1] = f res[index + 2] = e index = index + 3 @@ -2563,11 +2532,11 @@ end function ZZBase64.__decodeLeft1(res, index, text, len) local decode = ZZBase64.__decode - local a = decode[string.byte(text, len + 1)] - local b = decode[string.byte(text, len + 2)] - local c = decode[string.byte(text, len + 3)] + local a = decode[string.byte(text, len + 1)] + local b = decode[string.byte(text, len + 2)] + local c = decode[string.byte(text, len + 3)] local num = a * 4096 + b * 64 + c - + local num1 = math.floor(num / 1024) % 256 local num2 = math.floor(num / 4) % 256 res[index] = string.char(num1) @@ -2576,14 +2545,11 @@ end function ZZBase64.__decodeLeft2(res, index, text, len) local decode = ZZBase64.__decode - local a = decode[string.byte(text, len + 1)] + local a = decode[string.byte(text, len + 1)] local b = decode[string.byte(text, len + 2)] local num = a * 64 + b num = math.floor(num / 16) res[index] = string.char(num) end - - - return StartDebug diff --git a/lua_probject/base_project/Main.lua b/lua_probject/base_project/Main.lua index 8c88d763..0d1d9663 100644 --- a/lua_probject/base_project/Main.lua +++ b/lua_probject/base_project/Main.lua @@ -1,14 +1,15 @@ -local breakSocketHandle,debugXpCall = require("LuaDebugjit")("localhost",7003) -local timer = Timer.New(function() -breakSocketHandle() end, 1, -1, false) +local breakSocketHandle, debugXpCall = require("LuaDebugjit")("localhost", 7003) +local timer = Timer.New(function() + breakSocketHandle() +end, 1, -1, false) timer:Start(); require "Core.init" json = require 'cjson' -require'FairyGUI' -require'Game.ControllerManager' -require'Game.ViewManager' -require'Game.DataManager' +require 'FairyGUI' +require 'Game.ControllerManager' +require 'Game.ViewManager' +require 'Game.DataManager' require "Game.ExtendManager" require "Game.ExtendHotupdate" require "TableData" @@ -19,10 +20,10 @@ Utils = Game.Utils PlayerPrefs = UnityEngine.PlayerPrefs RuntimePlatform = UnityEngine.RuntimePlatform Application = UnityEngine.Application -Screen=UnityEngine.Screen +Screen = UnityEngine.Screen ResourcesManager = taurus.unity.ResourcesManager --- require 'tolua.reflection' --- tolua.loadassembly('Assembly-CSharp') +-- require 'tolua.reflection' +-- tolua.loadassembly('Assembly-CSharp') -- local BindingFlags = require 'System.Reflection.BindingFlags' @@ -31,21 +32,22 @@ local _game_info local panel = nil -oldGameVersion=2 --1 原始 2 老游戏新加功能 +oldGameVersion = 2 --1 原始 2 老游戏新加功能 --主入口函数。从这里开始lua逻辑 function Main() - --PlayerPrefs.DeleteKey('session_id') + --PlayerPrefs.DeleteKey('session_id') Application.targetFrameRate = 60 - FairyGUI.UIConfig.buttonSound =FairyGUI.NAudioClip(ResourcesManager.LoadObject("base/common/sound/click.mp3",typeof(UnityEngine.AudioClip))) + FairyGUI.UIConfig.buttonSound = FairyGUI.NAudioClip(ResourcesManager.LoadObject("base/common/sound/click.mp3", + typeof(UnityEngine.AudioClip))) FairyGUI.UIConfig.defaultFont = "FZDaBiaoSong-B06S" - FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("SIYUAN","base/static/fonts/SIYUAN.TTF"),null) - --FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("FZCuYuan-M03","base/static/fonts/FZCuYuan-M03.TTF"),null) - --FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("HYFangLiJ","base/static/fonts/HYFangLiJ.ttf"),null) - _game_info = json.decode(GameApplication.Instance.GameInfo) - --_game_info["login_url"]="http://8.134.59.224:8101/" - --pt(_game_info) - debug_print = false--GetGameInfo("debug_print") + FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("SIYUAN", "base/static/fonts/SIYUAN.TTF"), null) + --FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("FZCuYuan-M03","base/static/fonts/FZCuYuan-M03.TTF"),null) + --FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("HYFangLiJ","base/static/fonts/HYFangLiJ.ttf"),null) + _game_info = json.decode(GameApplication.Instance.GameInfo) + --_game_info["login_url"]="http://8.134.59.224:8101/" + --pt(_game_info) + debug_print = false --GetGameInfo("debug_print") if Application.platform == RuntimePlatform.WindowsEditor then debug_print = true end @@ -53,7 +55,7 @@ function Main() NetManager.debug_print = debug_print -- 网络延时8秒 NetManager.TIMEOUT_TIME = 10 - + UIPackage.AddPackage("base/common/ui/Common") panel = UIPackage.CreateObjectFromURL("ui://Common/UIPanel") GRoot.inst:AddChildAt(panel, 0) @@ -62,7 +64,7 @@ function Main() --web网络API版本号 NetManager.VERSION = GetGameInfo("net_version") - TimerManager.New() + TimerManager.New() -- test:DynamicInvoke("222") --ExtendManager.Init() ControllerManager.Init() @@ -74,7 +76,7 @@ function Main() get_gps() local timer = 0 - local DSTweenManager = ds.tween.DSTweenManager + local DSTweenManager = ds.tween.DSTweenManager UpdateBeat:Add(function() local deltaTime = Time.deltaTime DSTweenManager.Update(deltaTime) @@ -89,10 +91,8 @@ function Main() end end end) - end - function GetGameInfo(key) return _game_info[key] end @@ -102,12 +102,12 @@ function GetPlatform() end function GetGameInfoPlatform(key) - local p_key = GetPlatform() + local p_key = GetPlatform() local _platfrom = _game_info[p_key] return _platfrom[key] end -function BlurView(view,enabled) +function BlurView(view, enabled) if enabled then local bf = FairyGUI.BlurFilter() bf.blurSize = 0.05 @@ -135,61 +135,60 @@ end function ShareScreenShot(n, callback) local json_data = {} json_data["title"] = "湘北联赛" - local mediaObject = {} + local mediaObject = {} mediaObject["path"] = Application.persistentDataPath mediaObject["filename"] = "screenshot" mediaObject["type"] = 1 json_data["mediaObject"] = mediaObject json_data["description"] = "一款现实中朋友约局休闲娱乐的场所!速度约朋友一起来玩吧!" json_data["scene"] = 0 - local json_str =json.encode(json_data) + local json_str = json.encode(json_data) TakeScreenShot.Take(function() - -- 1微信 2支付宝 - GameApplication.Instance:ShareLink(n or 1, json_str, nil) + -- 1微信 2支付宝 + GameApplication.Instance:ShareLink(n or 1, json_str, nil) if callback then callback() end end) end -function shareQRCodePicture(url,secene) - --print(debug.traceback()) - print(url) - print(secene) +function shareQRCodePicture(url, secene) + ---- print(debug.traceback()) + -- print(url) + -- print(secene) local json_data = {} json_data["title"] = "湘北联赛" local mediaObject = {} local filename = "qrcode" .. DataManager.SelfUser.account_id - print(Application.persistentDataPath) + -- print(Application.persistentDataPath) mediaObject["path"] = Application.persistentDataPath mediaObject["filename"] = filename mediaObject["type"] = 1 json_data["mediaObject"] = mediaObject json_data["description"] = "一款现实中朋友约局休闲娱乐的场所!速度约朋友一起来玩吧!" json_data["scene"] = secene - print("json_data==================") + -- print("json_data==================") local json_str = json.encode(json_data) - pt(json_str) + pt(json_str) local tex2 = QRCodePicture.GenerateQRcode(url, 250, 250) - local tex1 = ResourcesManager.LoadObject("base/lobby/bg/bg.png",typeof(UnityEngine.Texture2D)) - filename = filename ..".jpg" - print("text2==========") - print(tex2) - print("text1==========") - print(tex1) - print("filename==========") - print(filename) - QRCodePicture.CombanitePicture(tex1,tex2,393,1334-802-250,filename) - + local tex1 = ResourcesManager.LoadObject("base/lobby/bg/bg.png", typeof(UnityEngine.Texture2D)) + filename = filename .. ".jpg" + -- print("text2==========") + -- print(tex2) + -- print("text1==========") + -- print(tex1) + -- print("filename==========") + -- print(filename) + QRCodePicture.CombanitePicture(tex1, tex2, 393, 1334 - 802 - 250, filename) + GameApplication.Instance:ShareLink(1, json_str, nil) end - function ShareChatRoom(room_id, share_time, round, game_name, group_id, player_list, _root_view, play_name) - + end -function UISetController(root,controller_name, gear_display, selectedIndex) +function UISetController(root, controller_name, gear_display, selectedIndex) local ctr = root:GetController(controller_name) local gear = gear_display:GetGear(0) @@ -202,15 +201,15 @@ local bg_url = nil function LoadGameBg(url, main_view) local win_mode = main_view:GetChild("win_mode") win_mode:RemoveChildren(0, -1, true) - local tex_bg = ResourcesManager.LoadObjectByGroup(url..".png",typeof(UnityEngine.Texture), url) - print("===========================mainbg") - print(url..".png",typeof(UnityEngine.Texture), url) + local tex_bg = ResourcesManager.LoadObjectByGroup(url .. ".png", typeof(UnityEngine.Texture), url) + -- print("===========================mainbg") + -- print(url..".png",typeof(UnityEngine.Texture), url) local bg = GImage() bg.texture = FairyGUI.NTexture(tex_bg) bg.width = win_mode.width bg.height = win_mode.height bg:AddRelation(win_mode, RelationType.Size) - win_mode:AddChild(bg) + win_mode:AddChild(bg) -- 卸载资源 if url ~= bg_url and bg_url then @@ -225,7 +224,7 @@ function AddPanel(child) panel:AddChild(child) end -function AddPanelAt(child,index) +function AddPanelAt(child, index) child:MakeFullScreen() child:AddRelation(GRoot.inst, RelationType.Size) panel:AddChildAt(child, index) @@ -247,7 +246,7 @@ end --场景切换通知 function OnLevelWasLoaded(level) - Time.timeSinceLevelLoad = 0 + Time.timeSinceLevelLoad = 0 end --程序切到后台 @@ -261,118 +260,111 @@ function OnApplicationActive() ViewManager.OnApplicationActive() end - - function pt(...) - if debug_print then - local arg={...} - local has=false - for _,v in pairs(arg) do - if v and type(v)=="table" then - has=true - break - end - end - if not has then - print(...) - end - - local content="" - for _,v in pairs(arg) do - if v=="table" then - content=content..tostring(v).."\n" - else - content=content.."==>[T]:"..LuaPrint(v,limit),debug.traceback().."\n" - end - print(content) - end - - end + if debug_print then + local arg = { ... } + local has = false + for _, v in pairs(arg) do + if v and type(v) == "table" then + has = true + break + end + end + if not has then + -- print(...) + end + + local content = "" + for _, v in pairs(arg) do + if v == "table" then + content = content .. tostring(v) .. "\n" + else + content = content .. "==>[T]:" .. LuaPrint(v, limit), debug.traceback() .. "\n" + end + -- print(content) + end + end end +function LuaPrint(lua_table, limit, indent, step) + step = step or 0 + indent = indent or 0 + local content = "" + if limit ~= nil then + if step > limit then + return "..." + end + end + if step > 10 then + return content .. "..." + end + if lua_table == nil then + return "nil" + end + if type(lua_table) == "userdata" or type(lua_table) == "lightuserdata" or type(lua_table) == "thread" then + return tostring(lua_table) + end -function LuaPrint(lua_table,limit,indent,step) - step=step or 0 - indent=indent or 0 - local content="" - if limit~=nil then - if step>limit then - return "..." - end - end - if step>10 then - return content.."..." - end - if lua_table==nil then - return "nil" - end - if type(lua_table)=="userdata" or type(lua_table)=="lightuserdata" or type(lua_table)=="thread" then - return tostring(lua_table) - end + if type(lua_table) == "string" or type(lua_table) == "number" then + return "[No-Table]:" .. lua_table + end - if type(lua_table)=="string" or type(lua_table)=="number" then - return "[No-Table]:"..lua_table - end - - for k,v in pairs(lua_table) do - if k~="_class_type" then - local szBuffer="" - Typev=type(v) - if Typev =="table" then - szBuffer="{" - end - local szPrefix=string.rep(" ",indent) - if Typev=="table" and v._fields then - local kk,vv=next(v._fields) - if type(vv)=="table" then - content=content.."\n\t"..kk.name.."={"..LuaPrint(vv._fields,5,indent+1,step+1).."}" - else - content=content.."\n\t"..kk.name.."="..vv - end - else - if type(k)=="table" then - if k.name then - if type(v)~="table" then - content=content.."\n"..k.name.."="..v - else - content=content.."\n"..k.name.." = list:" - local tmp="\n" - for ka,va in ipairs(v) do - tmp=tmp.."#"..ka.."_"..tostring(va) - end - content=content..tmp - end - end - - elseif type(k)=="function" then - content=content.."\n fun=function" - else - formatting=szPrefix..tostring(k).." = "..szBuffer - if Typev=="table" then - content=content.."\n"..formatting - content=content..LuaPrint(v,limit,indent+1,step+1) - content=content.."\n"..szPrefix.."}," - else - local szValue="" - if Typev=="string" then - szValue=string.format("%q",v) - else - szValue=tostring(v) - end - content=content.."\n"..formatting..(szValue or "nil").."," - end - end - - - end - end - end - return content + for k, v in pairs(lua_table) do + if k ~= "_class_type" then + local szBuffer = "" + Typev = type(v) + if Typev == "table" then + szBuffer = "{" + end + local szPrefix = string.rep(" ", indent) + if Typev == "table" and v._fields then + local kk, vv = next(v._fields) + if type(vv) == "table" then + content = content .. "\n\t" .. kk.name .. "={" .. LuaPrint(vv._fields, 5, indent + 1, step + 1) .. + "}" + else + content = content .. "\n\t" .. kk.name .. "=" .. vv + end + else + if type(k) == "table" then + if k.name then + if type(v) ~= "table" then + content = content .. "\n" .. k.name .. "=" .. v + else + content = content .. "\n" .. k.name .. " = list:" + local tmp = "\n" + for ka, va in ipairs(v) do + tmp = tmp .. "#" .. ka .. "_" .. tostring(va) + end + content = content .. tmp + end + end + elseif type(k) == "function" then + content = content .. "\n fun=function" + else + formatting = szPrefix .. tostring(k) .. " = " .. szBuffer + if Typev == "table" then + content = content .. "\n" .. formatting + content = content .. LuaPrint(v, limit, indent + 1, step + 1) + content = content .. "\n" .. szPrefix .. "}," + else + local szValue = "" + if Typev == "string" then + szValue = string.format("%q", v) + else + szValue = tostring(v) + end + content = content .. "\n" .. formatting .. (szValue or "nil") .. "," + end + end + end + end + end + return content end - function printlog(...) - if debug_print then - print(...) - end -end \ No newline at end of file + if debug_print then + -- print(...) + end +end diff --git a/lua_probject/base_project/debug/LuaDebug.lua b/lua_probject/base_project/debug/LuaDebug.lua index f7481d24..9d591912 100644 --- a/lua_probject/base_project/debug/LuaDebug.lua +++ b/lua_probject/base_project/debug/LuaDebug.lua @@ -1,7 +1,7 @@ -local debugger_reLoadFile =nil -xpcall(function() +local debugger_reLoadFile = nil +xpcall(function() debugger_reLoadFile = require("luaideReLoadFile") -end,function() +end, function() debugger_reLoadFile = function() print("未实现代码重载") end end) local debugger_stackInfo = nil @@ -21,27 +21,27 @@ local setfenv = setfenv if (not setfenv) then setfenv = function(fn, env) - local i = 1 - while true do - local name = debug.getupvalue(fn, i) - if name == "_ENV" then - debug.upvaluejoin( - fn, - i, - (function() - return env - end), - 1 - ) - break - elseif not name then - break - end + local i = 1 + while true do + local name = debug.getupvalue(fn, i) + if name == "_ENV" then + debug.upvaluejoin( + fn, + i, + (function() + return env + end), + 1 + ) + break + elseif not name then + break + end - i = i + 1 + i = i + 1 + end + return fn end - return fn - end end local ZZBase64 = {} local LuaDebugTool_ = nil @@ -154,50 +154,50 @@ local function createSocket() sinkt["close-when-done"] = function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if not chunk then - sock:close() - return 1 - else - return sock:send(chunk) + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - end - } - ) - end + }, + { + __call = function(self, chunk, err) + if not chunk then + sock:close() + return 1 + else + return sock:send(chunk) + end + end + } + ) + end sinkt["keep-open"] = function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if chunk then - return sock:send(chunk) - else - return 1 + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - end - } - ) - end + }, + { + __call = function(self, chunk, err) + if chunk then + return sock:send(chunk) + else + return 1 + end + end + } + ) + end sinkt["default"] = sinkt["keep-open"] @@ -205,63 +205,63 @@ local function createSocket() sourcet["by-length"] = function(sock, length) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if length <= 0 then - return nil + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local size = math.min(socket.BLOCKSIZE, length) - local chunk, err = sock:receive(size) - if err then - return nil, err + }, + { + __call = function() + if length <= 0 then + return nil + end + local size = math.min(socket.BLOCKSIZE, length) + local chunk, err = sock:receive(size) + if err then + return nil, err + end + length = length - string.len(chunk) + return chunk end - length = length - string.len(chunk) - return chunk - end - } - ) - end + } + ) + end sourcet["until-closed"] = function(sock) - local done - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if done then - return nil + local done + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local chunk, err, partial = sock:receive(socket.BLOCKSIZE) - if not err then - return chunk - elseif err == "closed" then - sock:close() - done = 1 - return partial - else - return nil, err + }, + { + __call = function() + if done then + return nil + end + local chunk, err, partial = sock:receive(socket.BLOCKSIZE) + if not err then + return chunk + elseif err == "closed" then + sock:close() + done = 1 + return partial + else + return nil, err + end end - end - } - ) - end + } + ) + end sourcet["default"] = sourcet["until-closed"] @@ -278,7 +278,7 @@ local function createJson() ----------------------------------------------------------------------------- -- Module declaration ----------------------------------------------------------------------------- - local json = {} -- Public namespace + local json = {} -- Public namespace local json_private = {} -- Private namespace -- Public constants @@ -392,6 +392,7 @@ local function createJson() function json.null() return json.null -- so json.null() will also return null ;-) end + ----------------------------------------------------------------------------- -- Internal, PRIVATE functions. -- Following a Python-like convention, I have prefixed all these 'PRIVATE' @@ -449,8 +450,8 @@ local function createJson() -- @return object, int The object (true, false or nil) and the position at which the next character should be -- scanned. function decode_scanConstant(s, startPos) - local consts = {["true"] = true, ["false"] = false, ["null"] = nil} - local constNames = {"true", "false", "null"} + local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } + local constNames = { "true", "false", "null" } for i, k in pairs(constNames) do if string.sub(s, startPos, startPos + string.len(k) - 1) == k then @@ -599,7 +600,7 @@ local function createJson() assert( string.find(s, startChar, j + 1), "String decoding failed: missing closing " .. - startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" + startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" ) return table.concat(t, ""), j + 2 -- END SoniEx2 @@ -675,13 +676,13 @@ local function createJson() if v ~= (t.n or #t) then return false end -- False if n does not hold the number of elements - else -- Else of (k=='n') + else -- Else of (k=='n') if isEncodable(v) then return false end end -- End of (k~='n') - end -- End of k,v not an indexed pair - end -- End of loop across all pairs + end -- End of k,v not an indexed pair + end -- End of loop across all pairs return true, maxIndex end @@ -704,7 +705,7 @@ local breakInfoSocket = nil local json = createJson() local LuaDebugger = { fileMaps = {}, - Run = true, --表示正常运行只检测断点 + Run = true, --表示正常运行只检测断点 StepIn = false, StepInLevel = 0, StepNext = false, @@ -776,17 +777,17 @@ function print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} + arg = { "nil" } end for k, v in pairs(arg) do str = str .. tostring(v) .. "\t" end local sendMsg = { event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 1} + data = { msg = ZZBase64.encode(str), type = 1 } } local sendStr = json.encode(sendMsg) debug_server:send(sendStr .. "__debugger_k0204__") @@ -800,46 +801,48 @@ function luaIdePrintWarn(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} + arg = { "nil" } end for k, v in pairs(arg) do str = str .. tostring(v) .. "\t" end local sendMsg = { event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 2} + data = { msg = ZZBase64.encode(str), type = 2 } } local sendStr = json.encode(sendMsg) debug_server:send(sendStr .. "__debugger_k0204__") end end end + function luaIdePrintErr(...) if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then debugger_print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} + arg = { "nil" } end for k, v in pairs(arg) do str = str .. tostring(v) .. "\t" end local sendMsg = { event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 3} + data = { msg = ZZBase64.encode(str), type = 3 } } local sendStr = json.encode(sendMsg) debug_server:send(sendStr .. "__debugger_k0204__") end end end + --@endregion --@region 辅助方法 @@ -876,7 +879,7 @@ local function debugger_getFilePathInfo(file) file = file:gsub("/.\\", "/") file = file:gsub("\\", "/") file = file:gsub("//", "/") - + if file:find("@") == 1 then file = file:sub(2) @@ -977,7 +980,7 @@ local function debugger_dump(value, desciption, nesting) return tostring(v) end local traceback = debugger_strSplit(debug.traceback("", 2), "\n") - print("dump from: " .. debugger_strTrim(traceback[3])) + -- print("dump from: " .. debugger_strTrim(traceback[3])) local function _dump(value, desciption, indent, nest, keylen) desciption = desciption or "" local spc = "" @@ -1026,30 +1029,28 @@ local function debugger_dump(value, desciption, nesting) end _dump(value, desciption, "- ", 1) for i, line in ipairs(result) do - print(line) + -- print(line) end end --@endregion local function debugger_valueToString(v) - local vtype = type(v) + local vtype = type(v) local vstr = nil if (vtype == "userdata") then if (LuaDebugger.isFoxGloryProject) then - - return "userdata",vtype - + return "userdata", vtype else return tostring(v), vtype end elseif (vtype == "table" or vtype == "function" or vtype == "boolean") then local value = vtype - xpcall(function() + xpcall(function() value = tostring(v) - end,function() + end, function() value = vtype end) return value, vtype - elseif (vtype == "number" or vtype == "string" ) then + elseif (vtype == "number" or vtype == "string") then return v, vtype else return tostring(v), vtype @@ -1057,12 +1058,12 @@ local function debugger_valueToString(v) end local function debugger_setVarInfo(name, value) local valueStr, valueType = debugger_valueToString(value) - local nameStr,nameType = debugger_valueToString(name) - if(valueStr == nil) then + local nameStr, nameType = debugger_valueToString(name) + if (valueStr == nil) then valueStr = valueType end local valueInfo = { - name =nameStr, + name = nameStr, valueType = valueType, valueStr = ZZBase64.encode(valueStr) } @@ -1100,64 +1101,64 @@ local function debugger_getvalue(f) i = i + 1 end - return {locals = locals, ups = ups} + return { locals = locals, ups = ups } end --获取堆栈 debugger_stackInfo = function(ignoreCount, event) - local datas = {} - local stack = {} - local varInfos = {} - local funcs = {} - local index = 0 - for i = ignoreCount, 100 do - local source = getinfo(i) - local isadd = true - if (i == ignoreCount) then - local file = source.source - if (file:find(LuaDebugger.DebugLuaFie)) then - return + local datas = {} + local stack = {} + local varInfos = {} + local funcs = {} + local index = 0 + for i = ignoreCount, 100 do + local source = getinfo(i) + local isadd = true + if (i == ignoreCount) then + local file = source.source + if (file:find(LuaDebugger.DebugLuaFie)) then + return + end + if (file == "=[C]") then + isadd = false + end end - if (file == "=[C]") then - isadd = false + if not source then + break + end + if (isadd) then + local fullName, dir, fileName = debugger_getFilePathInfo(source.source) + local info = { + src = fullName, + scoreName = source.name, + currentline = source.currentline, + linedefined = source.linedefined, + what = source.what, + nameWhat = source.namewhat + } + index = i + local vars = debugger_getvalue(i + 1) + table.insert(stack, info) + table.insert(varInfos, vars) + table.insert(funcs, source.func) + end + if source.what == "main" then + break end end - if not source then - break - end - if (isadd) then - local fullName, dir, fileName = debugger_getFilePathInfo(source.source) - local info = { - src = fullName, - scoreName = source.name, - currentline = source.currentline, - linedefined = source.linedefined, - what = source.what, - nameWhat = source.namewhat - } - index = i - local vars = debugger_getvalue(i + 1) - table.insert(stack, info) - table.insert(varInfos, vars) - table.insert(funcs, source.func) - end - if source.what == "main" then - break - end - end - - local stackInfo = {stack = stack, vars = varInfos, funcs = funcs} - local data = { - stack = stackInfo.stack, - vars = stackInfo.vars, - funcs = stackInfo.funcs, - event = event, - funcsLength = #stackInfo.funcs, - upFunc = getinfo(ignoreCount - 3, "f").func - } - LuaDebugger.currentTempFunc = data.funcs[1] - return data -end + + local stackInfo = { stack = stack, vars = varInfos, funcs = funcs } + local data = { + stack = stackInfo.stack, + vars = stackInfo.vars, + funcs = stackInfo.funcs, + event = event, + funcsLength = #stackInfo.funcs, + upFunc = getinfo(ignoreCount - 3, "f").func + } + LuaDebugger.currentTempFunc = data.funcs[1] + return data + end --===========================点断信息================================================== --根据不同的游戏引擎进行定时获取断点信息 @@ -1167,37 +1168,37 @@ local function debugger_receiveDebugBreakInfo() if (jit) then if (LuaDebugger.debugLuaType ~= "jit") then local msg = "当前luajit版本为: " .. jit.version .. " 请使用LuaDebugjit 进行调试!" - print(msg) + -- print(msg) end end if (breakInfoSocket) then local msg, status = breakInfoSocket:receive() - if(LuaDebugger.isLaunch and status == "closed") then - os.exit() + if (LuaDebugger.isLaunch and status == "closed") then + os.exit() end if (msg) then local netData = json.decode(msg) if netData.event == LuaDebugger.event.S2C_SetBreakPoints then debugger_setBreak(netData.data) elseif netData.event == LuaDebugger.event.S2C_LoadLuaScript then - LuaDebugger.loadScriptBody = netData.data + LuaDebugger.loadScriptBody = netData.data debugger_exeLuaString() - debugger_sendMsg(breakInfoSocket,LuaDebugger.event.C2S_LoadLuaScript,LuaDebugger.loadScriptBody) + debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) elseif netData.event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.reLoadFileBody = netData.data LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) - print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + -- print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) LuaDebugger.reLoadFileBody.script = nil debugger_sendMsg( breakInfoSocket, LuaDebugger.event.C2S_ReLoadFile, { stack = LuaDebugger.reLoadFileBody - + } - ) - end + ) + end end end end @@ -1221,76 +1222,76 @@ local function splitFilePath(path) end debugger_setBreak = function(datas) - local breakInfos = LuaDebugger.breakInfos - for i, data in ipairs(datas) do - data.fileName = string.lower(data.fileName) - data.serverPath = string.lower(data.serverPath) - local breakInfo = breakInfos[data.fileName] - if (not breakInfo) then - breakInfos[data.fileName] = {} - breakInfo = breakInfos[data.fileName] - end - if (not data.breakDatas or #data.breakDatas == 0) then - breakInfo[data.serverPath] = nil - else - local fileBreakInfo = breakInfo[data.serverPath] - if (not fileBreakInfo) then - fileBreakInfo = { - pathNames = splitFilePath(data.serverPath), - --命中次數判斷計數器 - hitCounts = {} - } - breakInfo[data.serverPath] = fileBreakInfo + local breakInfos = LuaDebugger.breakInfos + for i, data in ipairs(datas) do + data.fileName = string.lower(data.fileName) + data.serverPath = string.lower(data.serverPath) + local breakInfo = breakInfos[data.fileName] + if (not breakInfo) then + breakInfos[data.fileName] = {} + breakInfo = breakInfos[data.fileName] end - local lineInfos = {} - for li, breakData in ipairs(data.breakDatas) do - lineInfos[breakData.line] = breakData - if (breakData.hitCondition and breakData.hitCondition ~= "") then - breakData.hitCondition = tonumber(breakData.hitCondition) - else - breakData.hitCondition = 0 + if (not data.breakDatas or #data.breakDatas == 0) then + breakInfo[data.serverPath] = nil + else + local fileBreakInfo = breakInfo[data.serverPath] + if (not fileBreakInfo) then + fileBreakInfo = { + pathNames = splitFilePath(data.serverPath), + --命中次數判斷計數器 + hitCounts = {} + } + breakInfo[data.serverPath] = fileBreakInfo end - if (not fileBreakInfo.hitCounts[breakData.line]) then - fileBreakInfo.hitCounts[breakData.line] = 0 + local lineInfos = {} + for li, breakData in ipairs(data.breakDatas) do + lineInfos[breakData.line] = breakData + if (breakData.hitCondition and breakData.hitCondition ~= "") then + breakData.hitCondition = tonumber(breakData.hitCondition) + else + breakData.hitCondition = 0 + end + if (not fileBreakInfo.hitCounts[breakData.line]) then + fileBreakInfo.hitCounts[breakData.line] = 0 + end + end + fileBreakInfo.lines = lineInfos + --這裡添加命中次數判斷 + for line, count in pairs(fileBreakInfo.hitCounts) do + if (not lineInfos[line]) then + fileBreakInfo.hitCounts[line] = nil + end end end - fileBreakInfo.lines = lineInfos - --這裡添加命中次數判斷 - for line, count in pairs(fileBreakInfo.hitCounts) do - if (not lineInfos[line]) then - fileBreakInfo.hitCounts[line] = nil - end + local count = 0 + for i, linesInfo in pairs(breakInfo) do + count = count + 1 + end + if (count == 0) then + breakInfos[data.fileName] = nil end end - local count = 0 - for i, linesInfo in pairs(breakInfo) do - count = count + 1 + --debugger_dump(breakInfos, "breakInfos", 6) + --检查是否需要断点 + local isHook = false + for k, v in pairs(breakInfos) do + isHook = true + break end - if (count == 0) then - breakInfos[data.fileName] = nil - end - end - --debugger_dump(breakInfos, "breakInfos", 6) - --检查是否需要断点 - local isHook = false - for k, v in pairs(breakInfos) do - isHook = true - break - end - --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 - if (isHook) then - if (not LuaDebugger.isHook) then - debug.sethook(debug_hook, "lrc") + --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 + if (isHook) then + if (not LuaDebugger.isHook) then + debug.sethook(debug_hook, "lrc") + end + LuaDebugger.isHook = true + else + if (LuaDebugger.isHook) then + debug.sethook() + end + LuaDebugger.isHook = false end - LuaDebugger.isHook = true - else - if (LuaDebugger.isHook) then - debug.sethook() - end - LuaDebugger.isHook = false end -end local function debugger_checkFileIsBreak(fileName) return LuaDebugger.breakInfos[fileName] end @@ -1322,31 +1323,30 @@ function debugger_conditionStr(condition, vars, callBack) currentTabble[k] = v end end - setmetatable(currentTabble, {__index = _G}) + setmetatable(currentTabble, { __index = _G }) local fun = loadstring("return " .. condition) setfenv(fun, currentTabble) return fun() end local status, - msg = + msg = xpcall( - loadScript, - function(error) - print(error) - end - ) + loadScript, + function(error) + -- print(error) + end + ) if (status and msg) then callBack() end end + --执行lua字符串 debugger_exeLuaString = function() - local function loadScript() - local script = LuaDebugger.loadScriptBody.script if (LuaDebugger.loadScriptBody.isBreak) then - local currentTabble = {_G = _G} + local currentTabble = { _G = _G } local frameId = LuaDebugger.loadScriptBody.frameId frameId = frameId local func = LuaDebugger.currentDebuggerData.funcs[frameId] @@ -1359,8 +1359,8 @@ debugger_exeLuaString = function() for k, v in pairs(locals) do currentTabble[k] = v end - setmetatable(currentTabble, {__index = _G}) - + setmetatable(currentTabble, { __index = _G }) + local fun = loadstring(script) setfenv(fun, currentTabble) fun() @@ -1370,54 +1370,51 @@ debugger_exeLuaString = function() end end local status, - msg = + msg = xpcall( - loadScript, - function(error) - - -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) - end - ) - LuaDebugger.loadScriptBody.script = nil + loadScript, + function(error) + -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) + end + ) + LuaDebugger.loadScriptBody.script = nil if (LuaDebugger.loadScriptBody.isBreak) then - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack - end + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event + .C2S_HITBreakPoint) + LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack + end LuaDebugger.loadScriptBody.complete = true - end --@region 调试中修改变量值 --根据key 值在 value 查找 -local function debugger_getTablekey(key,keyType,value) - if(keyType == -1) then +local function debugger_getTablekey(key, keyType, value) + if (keyType == -1) then return key - elseif(keyType == 1) then + elseif (keyType == 1) then return tonumber(key) - elseif(keyType == 2) then + elseif (keyType == 2) then local valueKey = nil - for k,v in pairs(value) do + for k, v in pairs(value) do local nameType = type(k) - if(nameType == "userdata" or nameType == "table") then + if (nameType == "userdata" or nameType == "table") then if (not LuaDebugger.isFoxGloryProject) then valueKey = tostring(k) - if(key == valueKey) then + if (key == valueKey) then return k end break end end end - end end local function debugger_setVarValue(server, data) - local newValue = nil - local level = LuaDebugger.serVarLevel+LuaDebugger.setVarBody.frameId + local level = LuaDebugger.serVarLevel + LuaDebugger.setVarBody.frameId local firstKeyName = data.keys[1] --@region vars check local localValueChangeIndex = -1 @@ -1432,7 +1429,7 @@ local function debugger_setVarValue(server, data) if not name then break end - if(firstKeyName == name) then + if (firstKeyName == name) then localValueChangeIndex = i oldValue = value end @@ -1446,11 +1443,11 @@ local function debugger_setVarValue(server, data) local ups = {} while func do -- check for func as it may be nil for tail calls local name, value = debug.getupvalue(func, i) - + if not name then break end - if(localValueChangeIndex == -1 and firstKeyName == name) then + if (localValueChangeIndex == -1 and firstKeyName == name) then upValueFun = func oldValue = value upValueChangeIndex = i @@ -1462,9 +1459,9 @@ local function debugger_setVarValue(server, data) end i = i + 1 end ---@endregion - local vars = {locals = locals, ups = ups} - + --@endregion + local vars = { locals = locals, ups = ups } + local function loadScript() local currentTabble = {} local locals = vars.locals @@ -1480,58 +1477,56 @@ local function debugger_setVarValue(server, data) currentTabble[k] = v end end - setmetatable(currentTabble, {__index = _G}) + setmetatable(currentTabble, { __index = _G }) local fun = loadstring("return " .. data.value) setfenv(fun, currentTabble) newValue = fun() end local status, - msg = + msg = xpcall( - loadScript, - function(error) - print(error, "============================") - end - ) - + loadScript, + function(error) + -- print(error, "============================") + end + ) + local i = 1 - + -- local 查找并替换 local keyLength = #data.keys - - if(keyLength == 1) then - if(localValueChangeIndex ~= -1) then - + + if (keyLength == 1) then + if (localValueChangeIndex ~= -1) then debug.setlocal(level, localValueChangeIndex, newValue) - elseif(upValueFun ~= nil) then - debug.setupvalue( upValueFun, upValueChangeIndex, newValue ) + elseif (upValueFun ~= nil) then + debug.setupvalue(upValueFun, upValueChangeIndex, newValue) else --全局变量查找 - if(_G[firstKeyName]) then + if (_G[firstKeyName]) then _G[firstKeyName] = newValue end end else - if(not oldValue) then - if(_G[firstKeyName]) then + if (not oldValue) then + if (_G[firstKeyName]) then oldValue = _G[firstKeyName] end end local tempValue = oldValue - for i=2,keyLength-1 do - if(tempValue) then - oldValue = oldValue[debugger_getTablekey(data.keys[i],data.numberTypes[i],oldValue)] + for i = 2, keyLength - 1 do + if (tempValue) then + oldValue = oldValue[debugger_getTablekey(data.keys[i], data.numberTypes[i], oldValue)] end end - if(tempValue) then - oldValue[debugger_getTablekey(data.keys[keyLength],data.numberTypes[keyLength],oldValue)] = newValue + if (tempValue) then + oldValue[debugger_getTablekey(data.keys[keyLength], data.numberTypes[keyLength], oldValue)] = newValue end end - local varInfo = debugger_setVarInfo(data.varName, newValue) + local varInfo = debugger_setVarInfo(data.varName, newValue) data.varInfo = varInfo - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - end --@endregion @@ -1541,44 +1536,44 @@ end --调试修改变量值统一的 _resume checkSetVar = function() - if (LuaDebugger.isSetVar) then - LuaDebugger.isSetVar = false - debugger_setVarValue(debug_server,LuaDebugger.setVarBody) - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.setVarBody) - xpcall( - checkSetVar, - function(error) - print("设置变量", error) - end - ) - elseif(LuaDebugger.isLoadLuaScript) then - LuaDebugger.isLoadLuaScript = false - debugger_exeLuaString() - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("执行代码", error) - end - ) - elseif(LuaDebugger.isReLoadFile) then - LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) - print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) - LuaDebugger.reLoadFileBody.script = nil - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("重新加载文件", error) - end - ) + if (LuaDebugger.isSetVar) then + LuaDebugger.isSetVar = false + debugger_setVarValue(debug_server, LuaDebugger.setVarBody) + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.setVarBody) + xpcall( + checkSetVar, + function(error) + -- print("设置变量", error) + end + ) + elseif (LuaDebugger.isLoadLuaScript) then + LuaDebugger.isLoadLuaScript = false + debugger_exeLuaString() + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("执行代码", error) + end + ) + elseif (LuaDebugger.isReLoadFile) then + LuaDebugger.isReLoadFile = false + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + -- print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.script = nil + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("重新加载文件", error) + end + ) + end end -end - + local function getSource(source) @@ -1598,7 +1593,7 @@ local function debugger_GeVarInfoBytUserData(server, var) local fileds = LuaDebugTool.getUserDataInfo(var) local varInfos = {} - + --c# vars for i = 1, fileds.Count do @@ -1619,18 +1614,18 @@ end local function debugger_getValueByScript(value, script) local val = nil local status, - msg = + msg = xpcall( - function() - local fun = loadstring("return " .. script) - setfenv(fun, value) - val = fun() - end, - function(error) - print(error, "====>") - val = nil - end - ) + function() + local fun = loadstring("return " .. script) + setfenv(fun, value) + val = fun() + end, + function(error) + -- print(error, "====>") + val = nil + end + ) return val end @@ -1735,7 +1730,7 @@ end local function debugger_searchVarByKeys(value, keys, searckKeys) local index, val = debugger_getVarByKeys(value, searckKeys, 1) - if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then + if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then return index, val end if (val) then @@ -1863,9 +1858,9 @@ local function debugger_sendTableValues(value, server, variablesReference, debug if (valueType == "userdata") then m = getmetatable(value) - + vinfos = debugger_sendTableField(value, vinfos, server, variablesReference, debugSpeedIndex, valueType) - + if (LuaDebugTool) then local varInfos = debugger_GeVarInfoBytUserData(server, value, variablesReference, debugSpeedIndex) @@ -1894,7 +1889,6 @@ local function debugger_sendTableValues(value, server, variablesReference, debug vinfos = {} end end - end else m = getmetatable(value) @@ -1944,7 +1938,6 @@ local function debugger_getBreakVar(body, server) if (value) then local valueType = type(value) if (valueType == "table" or valueType == "userdata") then - debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) else if (valueType == "function") then @@ -1979,9 +1972,9 @@ local function debugger_getBreakVar(body, server) xpcall( exe, function(error) - -- print("获取变量错误 错误消息-----------------") - -- print(error) - -- print(debug.traceback("", 2)) + -- -- print("获取变量错误 错误消息-----------------") + -- -- print(error) + -- -- print(debug.traceback("", 2)) debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, @@ -2018,25 +2011,24 @@ local function debugger_loop(server) while true do local line, status = server:receive() if (status == "closed") then - if(LuaDebugger.isLaunch) then - os.exit() - else - debug.sethook() - coroutine.yield() - end + if (LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end end if (line) then local netData = json.decode(line) local event = netData.event local body = netData.data if (event == LuaDebugger.event.S2C_DebugClose) then - if(LuaDebugger.isLaunch) then - os.exit() - else - debug.sethook() - coroutine.yield() - end - + if (LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end elseif event == LuaDebugger.event.S2C_SetBreakPoints then --设置断点信息 local function setB() @@ -2045,7 +2037,7 @@ local function debugger_loop(server) xpcall( setB, function(error) - print(error) + -- print(error) end ) elseif event == LuaDebugger.event.S2C_RUN then --开始运行 @@ -2137,8 +2129,8 @@ local function debugger_loop(server) stack = data, eventType = data.eventType } - ) - elseif event == LuaDebugger.event.S2C_ReLoadFile then + ) + elseif event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.isReLoadFile = true LuaDebugger.reLoadFileBody = body local data = coroutine.yield() @@ -2156,29 +2148,26 @@ local function debugger_loop(server) end coro_debugger = coroutine.create(debugger_loop) debug_hook = function(event, line) - - if(not LuaDebugger.isHook) then + if (not LuaDebugger.isHook) then return end - - if(LuaDebugger.Run) then - if(event == "line") then + + if (LuaDebugger.Run) then + if (event == "line") then local isCheck = false for k, breakInfo in pairs(LuaDebugger.breakInfos) do - for bk, linesInfo in pairs(breakInfo) do - - if(linesInfo.lines and linesInfo.lines[line]) then + if (linesInfo.lines and linesInfo.lines[line]) then isCheck = true break end end - if(isCheck) then - break - end + if (isCheck) then + break + end end - if(not isCheck) then + if (not isCheck) then return end else @@ -2200,8 +2189,8 @@ debug_hook = function(event, line) else if (LuaDebugger.currentDebuggerData.funcs[2] == tempFun) then local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) - --挂起等待调试器作出反应 - + --挂起等待调试器作出反应 + _resume(coro_debugger, data) checkSetVar() end @@ -2209,7 +2198,7 @@ debug_hook = function(event, line) return end -- debugger_dump(LuaDebugger,"LuaDebugger") - -- print(LuaDebugger.StepNextLevel,"LuaDebugger.StepNextLevel") + -- -- print(LuaDebugger.StepNextLevel,"LuaDebugger.StepNextLevel") local file = nil if (event == "call") then -- end @@ -2217,7 +2206,7 @@ debug_hook = function(event, line) if (not LuaDebugger.Run) then LuaDebugger.StepNextLevel = LuaDebugger.StepNextLevel + 1 end - -- print("stepIn",LuaDebugger.StepNextLevel) + -- -- print("stepIn",LuaDebugger.StepNextLevel) local stepInfo = getinfo(2, "S") local source = stepInfo.source @@ -2254,12 +2243,11 @@ debug_hook = function(event, line) LuaDebugger.currentFileName = file end file = LuaDebugger.currentFileName - + --判断断点 local breakInfo = LuaDebugger.breakInfos[file] local breakData = nil if (breakInfo) then - local ischeck = false for k, lineInfo in pairs(breakInfo) do local lines = lineInfo.lines @@ -2268,7 +2256,7 @@ debug_hook = function(event, line) break end end - + if (ischeck) then --并且在断点中 local info = stepInfo @@ -2276,7 +2264,7 @@ debug_hook = function(event, line) info = getinfo(2) end local hitPathNames = splitFilePath(LuaDebugger.currentLineFile) - + local hitCounts = {} local debugHitCounts = nil for k, lineInfo in pairs(breakInfo) do @@ -2288,7 +2276,7 @@ debug_hook = function(event, line) --判断路径 hitCounts[k] = 0 local hitPathNamesCount = #hitPathNames - + local pathNamesCount = #pathNames local checkCount = 0; while (true) do @@ -2299,13 +2287,13 @@ debug_hook = function(event, line) end pathNamesCount = pathNamesCount - 1 hitPathNamesCount = hitPathNamesCount - 1 - checkCount = checkCount+1 - + checkCount = checkCount + 1 + if (pathNamesCount <= 0 or hitPathNamesCount <= 0) then break end end - if(checkCount>0) then + if (checkCount > 0) then break; end else @@ -2354,8 +2342,8 @@ debug_hook = function(event, line) local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) -- 挂起等待调试器作出反应 if (data) then - LuaDebugger.currentTempFunc = data.funcs[1] - + LuaDebugger.currentTempFunc = data.funcs[1] + _resume(coro_debugger, data) checkSetVar() return @@ -2384,8 +2372,8 @@ end local function debugger_xpcall() --调用 coro_debugger 并传入 参数 local data = debugger_stackInfo(4, LuaDebugger.event.C2S_HITBreakPoint) - if(data.stack and data.stack[1]) then - data.stack[1].isXpCall = true + if (data.stack and data.stack[1]) then + data.stack[1].isXpCall = true end --挂起等待调试器作出反应 _resume(coro_debugger, data) @@ -2396,8 +2384,8 @@ local function start() local fullName, dirName, fileName = debugger_getFilePathInfo(getinfo(1).source) LuaDebugger.DebugLuaFie = fileName local socket = createSocket() - print(controller_host) - print(controller_port) + -- print(controller_host) + -- print(controller_port) local server = socket.connect(controller_host, controller_port) debug_server = server @@ -2427,33 +2415,33 @@ local function start() debug.sethook(debug_hook, "lrc") end, function(error) - print("error:", error) + -- print("error:", error) end ) if (jit) then if (LuaDebugger.debugLuaType ~= "jit") then - print("error======================================================") + -- print("error======================================================") local msg = "当前luajit版本为: " .. jit.version .. " 请使用LuaDebugjit 进行调试!" - print(msg) + -- print(msg) end end - _resume(coro_debugger, server) + _resume(coro_debugger, server) end end end function StartDebug(host, port) if (not host) then - print("error host nil") + -- print("error host nil") end if (not port) then - print("error prot nil") + -- print("error prot nil") end if (type(host) ~= "string") then - print("error host not string") + -- print("error host not string") end if (type(port) ~= "number") then - print("error host not number") + -- print("error host not number") end controller_host = host controller_port = port @@ -2461,7 +2449,7 @@ function StartDebug(host, port) start, function(error) -- body - print(error) + -- print(error) end ) return debugger_receiveDebugBreakInfo, debugger_xpcall @@ -2478,25 +2466,25 @@ ZZBase64.__code = { 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', }; ZZBase64.__decode = {} -for k,v in pairs(ZZBase64.__code) do - ZZBase64.__decode[string.byte(v,1)] = k - 1 +for k, v in pairs(ZZBase64.__code) do + ZZBase64.__decode[string.byte(v, 1)] = k - 1 end function ZZBase64.encode(text) - local len = string.len(text) - local left = len % 3 - len = len - left - local res = {} - local index = 1 + local len = string.len(text) + local left = len % 3 + len = len - left + local res = {} + local index = 1 for i = 1, len, 3 do - local a = string.byte(text, i ) + local a = string.byte(text, i) local b = string.byte(text, i + 1) local c = string.byte(text, i + 2) -- num = a<<16 + b<<8 + c local num = a * 65536 + b * 256 + c for j = 1, 4 do --tmp = num >> ((4 -j) * 6) - local tmp = math.floor(num / (2 ^ ((4-j) * 6))) + local tmp = math.floor(num / (2 ^ ((4 - j) * 6))) --curPos = tmp&0x3f local curPos = tmp % 64 + 1 res[index] = ZZBase64.__code[curPos] @@ -2516,7 +2504,7 @@ function ZZBase64.__left2(res, index, text, len) local num1 = string.byte(text, len + 1) num1 = num1 * 1024 --lshift 10 local num2 = string.byte(text, len + 2) - num2 = num2 * 4 --lshift 2 + num2 = num2 * 4 --lshift 2 local num = num1 + num2 local tmp1 = math.floor(num / 4096) --rShift 12 @@ -2533,13 +2521,13 @@ function ZZBase64.__left2(res, index, text, len) res[index + 3] = "=" end -function ZZBase64.__left1(res, index,text, len) +function ZZBase64.__left1(res, index, text, len) local num = string.byte(text, len + 1) num = num * 16 local tmp = math.floor(num / 64) local curPos = tmp % 64 + 1 - res[index ] = ZZBase64.__code[curPos] + res[index] = ZZBase64.__code[curPos] curPos = num % 64 + 1 res[index + 1] = ZZBase64.__code[curPos] @@ -2562,11 +2550,11 @@ function ZZBase64.decode(text) local res = {} local index = 1 local decode = ZZBase64.__decode - for i =1, len, 4 do - local a = decode[string.byte(text,i )] - local b = decode[string.byte(text,i + 1)] - local c = decode[string.byte(text,i + 2)] - local d = decode[string.byte(text,i + 3)] + for i = 1, len, 4 do + local a = decode[string.byte(text, i)] + local b = decode[string.byte(text, i + 1)] + local c = decode[string.byte(text, i + 2)] + local d = decode[string.byte(text, i + 3)] --num = a<<18 + b<<12 + c<<6 + d local num = a * 262144 + b * 4096 + c * 64 + d @@ -2575,7 +2563,7 @@ function ZZBase64.decode(text) num = math.floor(num / 256) local f = string.char(num % 256) num = math.floor(num / 256) - res[index ] = string.char(num % 256) + res[index] = string.char(num % 256) res[index + 1] = f res[index + 2] = e index = index + 3 @@ -2611,7 +2599,4 @@ function ZZBase64.__decodeLeft2(res, index, text, len) res[index] = string.char(num) end - - - return StartDebug diff --git a/lua_probject/base_project/debug/LuaDebugjit.lua b/lua_probject/base_project/debug/LuaDebugjit.lua index 6ba9f888..c5a8613b 100644 --- a/lua_probject/base_project/debug/LuaDebugjit.lua +++ b/lua_probject/base_project/debug/LuaDebugjit.lua @@ -1,7 +1,7 @@ -local debugger_reLoadFile =nil -xpcall(function() +local debugger_reLoadFile = nil +xpcall(function() debugger_reLoadFile = require("luaideReLoadFile") -end,function() +end, function() debugger_reLoadFile = function() print("未实现代码重载") end end) local sethook = debug.sethook @@ -13,165 +13,165 @@ local checkSetVar = nil local loadstring_ = nil local debugger_sendMsg = nil if (loadstring) then -loadstring_ = loadstring + loadstring_ = loadstring else -loadstring_ = load + loadstring_ = load end local ZZBase64 = {} local LuaDebugTool_ = nil if (LuaDebugTool) then - LuaDebugTool_ = LuaDebugTool + LuaDebugTool_ = LuaDebugTool elseif (CS and CS.LuaDebugTool) then - LuaDebugTool_ = CS.LuaDebugTool + LuaDebugTool_ = CS.LuaDebugTool end local LuaDebugTool = LuaDebugTool_ local loadstring = loadstring_ local getinfo = debug.getinfo local function createSocket() - local base = _G - local string = require("string") - local math = require("math") - local socket = require("socket.core") - - local _M = socket - - ----------------------------------------------------------------------------- - -- Exported auxiliar functions - ----------------------------------------------------------------------------- - function _M.connect4(address, port, laddress, lport) - return socket.connect(address, port, laddress, lport, "inet") - end - - function _M.connect6(address, port, laddress, lport) - return socket.connect(address, port, laddress, lport, "inet6") - end + local base = _G + local string = require("string") + local math = require("math") + local socket = require("socket.core") - if (not _M.connect) then - function _M.connect(address, port, laddress, lport) - local sock, err = socket.tcp() - if not sock then - return nil, err - end - if laddress then - local res, err = sock:bind(laddress, lport, -1) - if not res then - return nil, err - end - end - local res, err = sock:connect(address, port) - if not res then + local _M = socket + + ----------------------------------------------------------------------------- + -- Exported auxiliar functions + ----------------------------------------------------------------------------- + function _M.connect4(address, port, laddress, lport) + return socket.connect(address, port, laddress, lport, "inet") + end + + function _M.connect6(address, port, laddress, lport) + return socket.connect(address, port, laddress, lport, "inet6") + end + + if (not _M.connect) then + function _M.connect(address, port, laddress, lport) + local sock, err = socket.tcp() + if not sock then return nil, err end - return sock - end - end - function _M.bind(host, port, backlog) - if host == "*" then + if laddress then + local res, err = sock:bind(laddress, lport, -1) + if not res then + return nil, err + end + end + local res, err = sock:connect(address, port) + if not res then + return nil, err + end + return sock + end + end + function _M.bind(host, port, backlog) + if host == "*" then host = "0.0.0.0" end local addrinfo, err = socket.dns.getaddrinfo(host) if not addrinfo then return nil, err end - local sock, res - err = "no info on address" - for i, alt in base.ipairs(addrinfo) do - if alt.family == "inet" then - sock, err = socket.tcp4() - else - sock, err = socket.tcp6() - end - if not sock then + local sock, res + err = "no info on address" + for i, alt in base.ipairs(addrinfo) do + if alt.family == "inet" then + sock, err = socket.tcp4() + else + sock, err = socket.tcp6() + end + if not sock then return nil, err end - sock:setoption("reuseaddr", true) - res, err = sock:bind(alt.addr, port) - if not res then - sock:close() - else - res, err = sock:listen(backlog) - if not res then - sock:close() - else - return sock - end - end - end - return nil, err - end - - _M.try = _M.newtry() - - function _M.choose(table) - return function(name, opt1, opt2) - if base.type(name) ~= "string" then - name, opt1, opt2 = "default", name, opt1 - end - local f = table[name or "nil"] - if not f then + sock:setoption("reuseaddr", true) + res, err = sock:bind(alt.addr, port) + if not res then + sock:close() + else + res, err = sock:listen(backlog) + if not res then + sock:close() + else + return sock + end + end + end + return nil, err + end + + _M.try = _M.newtry() + + function _M.choose(table) + return function(name, opt1, opt2) + if base.type(name) ~= "string" then + name, opt1, opt2 = "default", name, opt1 + end + local f = table[name or "nil"] + if not f then base.error("unknown key (" .. base.tostring(name) .. ")", 3) else return f(opt1, opt2) end - end - end - - ----------------------------------------------------------------------------- - -- Socket sources and sinks, conforming to LTN12 - ----------------------------------------------------------------------------- - -- create namespaces inside LuaSocket namespace - local sourcet, sinkt = {}, {} - _M.sourcet = sourcet - _M.sinkt = sinkt - - _M.BLOCKSIZE = 2048 - - sinkt["close-when-done"] = - function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if not chunk then - sock:close() - return 1 - else - return sock:send(chunk) - end - end - } - ) + end end + ----------------------------------------------------------------------------- + -- Socket sources and sinks, conforming to LTN12 + ----------------------------------------------------------------------------- + -- create namespaces inside LuaSocket namespace + local sourcet, sinkt = {}, {} + _M.sourcet = sourcet + _M.sinkt = sinkt + + _M.BLOCKSIZE = 2048 + + sinkt["close-when-done"] = + function(sock) + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() + end + }, + { + __call = function(self, chunk, err) + if not chunk then + sock:close() + return 1 + else + return sock:send(chunk) + end + end + } + ) + end + sinkt["keep-open"] = function(sock) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function(self, chunk, err) - if chunk then - return sock:send(chunk) - else - return 1 + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - end - } - ) - end + }, + { + __call = function(self, chunk, err) + if chunk then + return sock:send(chunk) + else + return 1 + end + end + } + ) + end sinkt["default"] = sinkt["keep-open"] @@ -179,133 +179,133 @@ local function createSocket() sourcet["by-length"] = function(sock, length) - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if length <= 0 then - return nil + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local size = math.min(socket.BLOCKSIZE, length) - local chunk, err = sock:receive(size) - if err then - return nil, err + }, + { + __call = function() + if length <= 0 then + return nil + end + local size = math.min(socket.BLOCKSIZE, length) + local chunk, err = sock:receive(size) + if err then + return nil, err + end + length = length - string.len(chunk) + return chunk end - length = length - string.len(chunk) - return chunk - end - } - ) - end + } + ) + end sourcet["until-closed"] = function(sock) - local done - return base.setmetatable( - { - getfd = function() - return sock:getfd() - end, - dirty = function() - return sock:dirty() - end - }, - { - __call = function() - if done then - return nil + local done + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() end - local chunk, err, partial = sock:receive(socket.BLOCKSIZE) - if not err then - return chunk - elseif err == "closed" then - sock:close() - done = 1 - return partial - else - return nil, err + }, + { + __call = function() + if done then + return nil + end + local chunk, err, partial = sock:receive(socket.BLOCKSIZE) + if not err then + return chunk + elseif err == "closed" then + sock:close() + done = 1 + return partial + else + return nil, err + end end - end - } - ) - end - - sourcet["default"] = sourcet["until-closed"] - - _M.source = _M.choose(sourcet) - - return _M + } + ) + end + + sourcet["default"] = sourcet["until-closed"] + + _M.source = _M.choose(sourcet) + + return _M end local function createJson() - local math = require("math") - local string = require("string") - local table = require("table") - local object = nil - ----------------------------------------------------------------------------- - -- Module declaration - ----------------------------------------------------------------------------- - local json = {} -- Public namespace + local math = require("math") + local string = require("string") + local table = require("table") + local object = nil + ----------------------------------------------------------------------------- + -- Module declaration + ----------------------------------------------------------------------------- + local json = {} -- Public namespace local json_private = {} -- Private namespace - - -- Public constants - json.EMPTY_ARRAY = {} - json.EMPTY_OBJECT = {} - -- Public functions - -- Private functions - local decode_scanArray - local decode_scanComment - local decode_scanConstant - local decode_scanNumber - local decode_scanObject - local decode_scanString - local decode_scanWhitespace - local encodeString - local isArray - local isEncodable - - ----------------------------------------------------------------------------- - -- PUBLIC FUNCTIONS - ----------------------------------------------------------------------------- - --- Encodes an arbitrary Lua object / variable. - -- @param v The Lua object / variable to be JSON encoded. - -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) - function json.encode(v) - -- Handle nil values - if v == nil then - return "null" - end - - local vtype = type(v) - - -- Handle strings - if vtype == "string" then + -- Public constants + json.EMPTY_ARRAY = {} + json.EMPTY_OBJECT = {} + -- Public functions + + -- Private functions + local decode_scanArray + local decode_scanComment + local decode_scanConstant + local decode_scanNumber + local decode_scanObject + local decode_scanString + local decode_scanWhitespace + local encodeString + local isArray + local isEncodable + + ----------------------------------------------------------------------------- + -- PUBLIC FUNCTIONS + ----------------------------------------------------------------------------- + --- Encodes an arbitrary Lua object / variable. + -- @param v The Lua object / variable to be JSON encoded. + -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) + function json.encode(v) + -- Handle nil values + if v == nil then + return "null" + end + + local vtype = type(v) + + -- Handle strings + if vtype == "string" then return '"' .. json_private.encodeString(v) .. '"' -- Need to handle encoding in string end - - -- Handle booleans - if vtype == "number" or vtype == "boolean" then + + -- Handle booleans + if vtype == "number" or vtype == "boolean" then return tostring(v) end - - -- Handle tables - if vtype == "table" then - local rval = {} - -- Consider arrays separately - local bArray, maxCount = isArray(v) - if bArray then - for i = 1, maxCount do - table.insert(rval, json.encode(v[i])) - end - else -- An object, not an array + + -- Handle tables + if vtype == "table" then + local rval = {} + -- Consider arrays separately + local bArray, maxCount = isArray(v) + if bArray then + for i = 1, maxCount do + table.insert(rval, json.encode(v[i])) + end + else -- An object, not an array for i, j in pairs(v) do if isEncodable(i) and isEncodable(j) then table.insert(rval, '"' .. json_private.encodeString(i) .. '":' .. json.encode(j)) @@ -317,23 +317,23 @@ local function createJson() else return "{" .. table.concat(rval, ",") .. "}" end - end - - -- Handle null values - if vtype == "function" and v == json.null then + end + + -- Handle null values + if vtype == "function" and v == json.null then return "null" end assert(false, "encode attempt to encode unsupported type " .. vtype .. ":" .. tostring(v)) end - - --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. - -- @param s The string to scan. - -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. - -- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, - -- and the position of the first character after - -- the scanned JSON object. - function json.decode(s, startPos) + + --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. + -- @param s The string to scan. + -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. + -- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, + -- and the position of the first character after + -- the scanned JSON object. + function json.decode(s, startPos) startPos = startPos and startPos or 1 startPos = decode_scanWhitespace(s, startPos) assert(startPos <= string.len(s), "Unterminated JSON encoded object found at position in [" .. s .. "]") @@ -366,18 +366,19 @@ local function createJson() function json.null() return json.null -- so json.null() will also return null ;-) end - ----------------------------------------------------------------------------- - -- Internal, PRIVATE functions. - -- Following a Python-like convention, I have prefixed all these 'PRIVATE' - -- functions with an underscore. - ----------------------------------------------------------------------------- - --- Scans an array from JSON into a Lua object - -- startPos begins at the start of the array. - -- Returns the array and the next starting position - -- @param s The string being scanned. - -- @param startPos The starting position for the scan. - -- @return table, int The scanned array as a table, and the position of the next character to scan. - function decode_scanArray(s, startPos) + + ----------------------------------------------------------------------------- + -- Internal, PRIVATE functions. + -- Following a Python-like convention, I have prefixed all these 'PRIVATE' + -- functions with an underscore. + ----------------------------------------------------------------------------- + --- Scans an array from JSON into a Lua object + -- startPos begins at the start of the array. + -- Returns the array and the next starting position + -- @param s The string being scanned. + -- @param startPos The starting position for the scan. + -- @return table, int The scanned array as a table, and the position of the next character to scan. + function decode_scanArray(s, startPos) local array = {} -- The return value local stringLen = string.len(s) assert( @@ -423,8 +424,8 @@ local function createJson() -- @return object, int The object (true, false or nil) and the position at which the next character should be -- scanned. function decode_scanConstant(s, startPos) - local consts = {["true"] = true, ["false"] = false, ["null"] = nil} - local constNames = {"true", "false", "null"} + local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } + local constNames = { "true", "false", "null" } for i, k in pairs(constNames) do if string.sub(s, startPos, startPos + string.len(k) - 1) == k then @@ -573,7 +574,7 @@ local function createJson() assert( string.find(s, startChar, j + 1), "String decoding failed: missing closing " .. - startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" + startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" ) return table.concat(t, ""), j + 2 -- END SoniEx2 @@ -649,13 +650,13 @@ local function createJson() if v ~= (t.n or #t) then return false end -- False if n does not hold the number of elements - else -- Else of (k=='n') + else -- Else of (k=='n') if isEncodable(v) then return false end end -- End of (k~='n') - end -- End of k,v not an indexed pair - end -- End of loop across all pairs + end -- End of k,v not an indexed pair + end -- End of loop across all pairs return true, maxIndex end @@ -677,64 +678,64 @@ local debug_server = nil local breakInfoSocket = nil local json = createJson() local LuaDebugger = { - fileMaps = {}, - Run = true, --表示正常运行只检测断点 - StepIn = false, - StepNext = false, - StepOut = false, - breakInfos = {}, - runTimeType = nil, - isHook = true, - pathCachePaths = {}, - isProntToConsole = 1, - isDebugPrint = true, - hookType = "lrc", - stepNextFun = nil, - DebugLuaFie = "", - runLineCount = 0, - --分割字符串缓存 - splitFilePaths = {}, - version="0.9.3", + fileMaps = {}, + Run = true, --表示正常运行只检测断点 + StepIn = false, + StepNext = false, + StepOut = false, + breakInfos = {}, + runTimeType = nil, + isHook = true, + pathCachePaths = {}, + isProntToConsole = 1, + isDebugPrint = true, + hookType = "lrc", + stepNextFun = nil, + DebugLuaFie = "", + runLineCount = 0, + --分割字符串缓存 + splitFilePaths = {}, + version = "0.9.3", serVarLevel = 4 } local debug_hook = nil local _resume = coroutine.resume coroutine.resume = function(co, ...) - if (LuaDebugger.isHook) then + if (LuaDebugger.isHook) then if coroutine.status(co) ~= "dead" then debug.sethook(co, debug_hook, "lrc") - end + end end return _resume(co, ...) end LuaDebugger.event = { - S2C_SetBreakPoints = 1, - C2S_SetBreakPoints = 2, - S2C_RUN = 3, - C2S_HITBreakPoint = 4, - S2C_ReqVar = 5, - C2S_ReqVar = 6, - --单步跳过请求 - S2C_NextRequest = 7, - --单步跳过反馈 - C2S_NextResponse = 8, - -- 单步跳过 结束 没有下一步 - C2S_NextResponseOver = 9, - --单步跳入 - S2C_StepInRequest = 10, - C2S_StepInResponse = 11, - --单步跳出 - S2C_StepOutRequest = 12, - --单步跳出返回 - C2S_StepOutResponse = 13, - --打印 - C2S_LuaPrint = 14, - S2C_LoadLuaScript = 16, - C2S_SetSocketName = 17, - C2S_LoadLuaScript = 18, - C2S_DebugXpCall = 20, - S2C_DebugClose = 21, + S2C_SetBreakPoints = 1, + C2S_SetBreakPoints = 2, + S2C_RUN = 3, + C2S_HITBreakPoint = 4, + S2C_ReqVar = 5, + C2S_ReqVar = 6, + --单步跳过请求 + S2C_NextRequest = 7, + --单步跳过反馈 + C2S_NextResponse = 8, + -- 单步跳过 结束 没有下一步 + C2S_NextResponseOver = 9, + --单步跳入 + S2C_StepInRequest = 10, + C2S_StepInResponse = 11, + --单步跳出 + S2C_StepOutRequest = 12, + --单步跳出返回 + C2S_StepOutResponse = 13, + --打印 + C2S_LuaPrint = 14, + S2C_LoadLuaScript = 16, + C2S_SetSocketName = 17, + C2S_LoadLuaScript = 18, + C2S_DebugXpCall = 20, + S2C_DebugClose = 21, S2C_SerVar = 24, C2S_SerVar = 25, S2C_ReLoadFile = 26, @@ -742,27 +743,27 @@ LuaDebugger.event = { } --@region print function print(...) - if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then debugger_print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} - end - for k, v in pairs(arg) do - str = str .. tostring(v) .. "\t" - end - local sendMsg = { - event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 1} - } - local sendStr = json.encode(sendMsg) - debug_server:send(sendStr .. "__debugger_k0204__") - end - end + arg = { "nil" } + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = { msg = ZZBase64.encode(str), type = 1 } + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end end function luaIdePrintWarn(...) @@ -771,46 +772,48 @@ function luaIdePrintWarn(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} - end - for k, v in pairs(arg) do - str = str .. tostring(v) .. "\t" - end - local sendMsg = { - event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 2} - } - local sendStr = json.encode(sendMsg) - debug_server:send(sendStr .. "__debugger_k0204__") - end - end + arg = { "nil" } + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = { msg = ZZBase64.encode(str), type = 2 } + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end end + function luaIdePrintErr(...) if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then debugger_print(...) end if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then if (debug_server) then - local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local arg = { ... } --这里的...和{}符号中间需要有空格号,否则会出错 local str = "" if (#arg == 0) then - arg = {"nil"} - end - for k, v in pairs(arg) do - str = str .. tostring(v) .. "\t" - end - local sendMsg = { - event = LuaDebugger.event.C2S_LuaPrint, - data = {msg = ZZBase64.encode(str), type = 3} - } - local sendStr = json.encode(sendMsg) - debug_server:send(sendStr .. "__debugger_k0204__") - end - end + arg = { "nil" } + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = { msg = ZZBase64.encode(str), type = 3 } + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end end + --@endregion --@region 辅助方法 @@ -841,23 +844,23 @@ local function debugger_convertParentDir(dir) end end -local function debugger_getFilePathInfo(file) - local fileName = nil +local function debugger_getFilePathInfo(file) + local fileName = nil local dir = nil file = file:gsub("/.\\", "/") - file = file:gsub("\\", "/") - file = file:gsub("//", "/") - + file = file:gsub("\\", "/") + file = file:gsub("//", "/") - if file:find("@") == 1 then + + if file:find("@") == 1 then file = file:sub(2) - end - local findex = file:find("%./") - if (findex == 1) then + end + local findex = file:find("%./") + if (findex == 1) then file = file:sub(3) end - file = debugger_convertParentDir(file) + file = debugger_convertParentDir(file) local fileLength = string.len(file) local suffixNames = { ".lua", @@ -886,8 +889,8 @@ local function debugger_getFilePathInfo(file) end local fileNameStartIndex = debugger_lastIndex(file, "/") if (fileNameStartIndex) then - fileName = string.sub(file, fileNameStartIndex + 1) - + fileName = string.sub(file, fileNameStartIndex + 1) + dir = string.sub(file, 1, fileNameStartIndex) file = dir .. fileName else @@ -898,12 +901,12 @@ local function debugger_getFilePathInfo(file) else dir = string.sub(file, 1, fileNameStartIndex) dir = dir:gsub("%.", "/") - fileName = string.sub(file, fileNameStartIndex + 1) - file = dir .. fileName + fileName = string.sub(file, fileNameStartIndex + 1) + file = dir .. fileName end - end + end - return file, dir, fileName + return file, dir, fileName end --@endregion @@ -915,25 +918,25 @@ end local function debugger_strSplit(input, delimiter) - input = tostring(input) - delimiter = tostring(delimiter) - if (delimiter == "") then + input = tostring(input) + delimiter = tostring(delimiter) + if (delimiter == "") then return false end - local pos, arr = 0, {} - -- for each divider found - for st, sp in function() + local pos, arr = 0, {} + -- for each divider found + for st, sp in function() return string.find(input, delimiter, pos, true) - end do - table.insert(arr, string.sub(input, pos, st - 1)) - pos = sp + 1 - end - table.insert(arr, string.sub(input, pos)) - return arr + end do + table.insert(arr, string.sub(input, pos, st - 1)) + pos = sp + 1 + end + table.insert(arr, string.sub(input, pos)) + return arr end local function debugger_strTrim(input) - input = string.gsub(input, "^[ \t\n\r]+", "") - return string.gsub(input, "[ \t\n\r]+$", "") + input = string.gsub(input, "^[ \t\n\r]+", "") + return string.gsub(input, "[ \t\n\r]+$", "") end local function debugger_dump(value, desciption, nesting) if type(nesting) ~= "number" then @@ -948,7 +951,7 @@ local function debugger_dump(value, desciption, nesting) return tostring(v) end local traceback = debugger_strSplit(debug.traceback("", 2), "\n") - print("dump from: " .. debugger_strTrim(traceback[3])) + -- print("dump from: " .. debugger_strTrim(traceback[3])) local function _dump(value, desciption, indent, nest, keylen) desciption = desciption or "" local spc = "" @@ -997,7 +1000,7 @@ local function debugger_dump(value, desciption, nesting) end _dump(value, desciption, "- ", 1) for i, line in ipairs(result) do - print(line) + -- print(line) end end --@endregion @@ -1005,27 +1008,24 @@ local function debugger_valueToString(v) local vtype = type(v) local vstr = nil if (vtype == "userdata") then - if (LuaDebugger.isFoxGloryProject ) then - - return "userdata",vtype - + if (LuaDebugger.isFoxGloryProject) then + return "userdata", vtype else return tostring(v), vtype end elseif (vtype == "table" or vtype == "function" or vtype == "boolean") then local value = vtype - xpcall(function() - if(LuaDebugger.isFoxGloryProject) then + xpcall(function() + if (LuaDebugger.isFoxGloryProject) then value = vtype else value = tostring(v) end - - end,function() + end, function() value = vtype end) return value, vtype - elseif (vtype == "number" or vtype == "string" ) then + elseif (vtype == "number" or vtype == "string") then return v, vtype else return tostring(v), vtype @@ -1033,12 +1033,12 @@ local function debugger_valueToString(v) end local function debugger_setVarInfo(name, value) local valueStr, valueType = debugger_valueToString(value) - local nameStr,nameType = debugger_valueToString(name) - if(valueStr == nil) then + local nameStr, nameType = debugger_valueToString(name) + if (valueStr == nil) then valueStr = valueType end local valueInfo = { - name =nameStr, + name = nameStr, valueType = valueType, valueStr = ZZBase64.encode(valueStr) } @@ -1047,283 +1047,282 @@ local function debugger_setVarInfo(name, value) end local function debugger_getvalue(f) - local i = 1 - local locals = {} - -- get locals - while true do - local name, value = debug.getlocal(f, i) - if not name then + local i = 1 + local locals = {} + -- get locals + while true do + local name, value = debug.getlocal(f, i) + if not name then break end if (name ~= "(*temporary)") then - locals[name] = value - end - i = i + 1 - end - local func = getinfo(f, "f").func - i = 1 - local ups = {} - while func do -- check for func as it may be nil for tail calls - local name, value = debug.getupvalue(func, i) - if not name then + locals[name] = value + end + i = i + 1 + end + local func = getinfo(f, "f").func + i = 1 + local ups = {} + while func do -- check for func as it may be nil for tail calls + local name, value = debug.getupvalue(func, i) + if not name then break end if (name == "_ENV") then - ups["_ENV_"] = value - else - ups[name] = value - end - i = i + 1 - end + ups["_ENV_"] = value + else + ups[name] = value + end + i = i + 1 + end - return {locals = locals, ups = ups} + return { locals = locals, ups = ups } end --获取堆栈 debugger_stackInfo = function(ignoreCount, event) - local datas = {} - local stack = {} - local varInfos = {} - local funcs = {} - local index = 0 - for i = ignoreCount, 100 do - local source = getinfo(i) - local isadd = true - if (i == ignoreCount) then - local file = source.source - if (file:find(LuaDebugger.DebugLuaFie)) then - return - end - if (file == "=[C]") then - isadd = false - end - end - if not source then - break - end - if (isadd) then - local fullName, dir, fileName = debugger_getFilePathInfo(source.source) - local info = { - src = fullName, - scoreName = source.name, - currentline = source.currentline, - linedefined = source.linedefined, - what = source.what, - nameWhat = source.namewhat - } - index = i - local vars = debugger_getvalue(i + 1) - table.insert(stack, info) - table.insert(varInfos, vars) - table.insert(funcs, source.func) - end - if source.what == "main" then - break + local datas = {} + local stack = {} + local varInfos = {} + local funcs = {} + local index = 0 + for i = ignoreCount, 100 do + local source = getinfo(i) + local isadd = true + if (i == ignoreCount) then + local file = source.source + if (file:find(LuaDebugger.DebugLuaFie)) then + return + end + if (file == "=[C]") then + isadd = false + end + end + if not source then + break + end + if (isadd) then + local fullName, dir, fileName = debugger_getFilePathInfo(source.source) + local info = { + src = fullName, + scoreName = source.name, + currentline = source.currentline, + linedefined = source.linedefined, + what = source.what, + nameWhat = source.namewhat + } + index = i + local vars = debugger_getvalue(i + 1) + table.insert(stack, info) + table.insert(varInfos, vars) + table.insert(funcs, source.func) + end + if source.what == "main" then + break + end end - end - local stackInfo = {stack = stack, vars = varInfos, funcs = funcs} - local data = { - stack = stackInfo.stack, - vars = stackInfo.vars, - funcs = stackInfo.funcs, - event = event, - funcsLength = #stackInfo.funcs, - upFunc = getinfo(ignoreCount - 3, "f").func - } + local stackInfo = { stack = stack, vars = varInfos, funcs = funcs } + local data = { + stack = stackInfo.stack, + vars = stackInfo.vars, + funcs = stackInfo.funcs, + event = event, + funcsLength = #stackInfo.funcs, + upFunc = getinfo(ignoreCount - 3, "f").func + } - return data -end + return data + end --==============================工具方法 end====================================================== --===========================点断信息================================================== --根据不同的游戏引擎进行定时获取断点信息 --CCDirector:sharedDirector():getScheduler() local debugger_setBreak = nil local function debugger_receiveDebugBreakInfo() - if(not jit) then - if(_VERSION)then - print("当前lua版本为: ".._VERSION.." 请使用 -----LuaDebug.lua----- 进行调试!") - else - print("当前为lua版本,请使用-----LuaDebug.lua-----进行调试!") - end - end - if (breakInfoSocket) then + if (not jit) then + if (_VERSION) then + -- print("当前lua版本为: ".._VERSION.." 请使用 -----LuaDebug.lua----- 进行调试!") + else + -- print("当前为lua版本,请使用-----LuaDebug.lua-----进行调试!") + end + end + if (breakInfoSocket) then local msg, status = breakInfoSocket:receive() - if(LuaDebugger.isLaunch == true and status == "closed") then + if (LuaDebugger.isLaunch == true and status == "closed") then os.exit() end - if (msg) then - local netData = json.decode(msg) - if netData.event == LuaDebugger.event.S2C_SetBreakPoints then - debugger_setBreak(netData.data) - elseif netData.event == LuaDebugger.event.S2C_LoadLuaScript then - LuaDebugger.loadScriptBody = netData.data + if (msg) then + local netData = json.decode(msg) + if netData.event == LuaDebugger.event.S2C_SetBreakPoints then + debugger_setBreak(netData.data) + elseif netData.event == LuaDebugger.event.S2C_LoadLuaScript then + LuaDebugger.loadScriptBody = netData.data debugger_exeLuaString() - debugger_sendMsg(breakInfoSocket,LuaDebugger.event.C2S_LoadLuaScript,LuaDebugger.loadScriptBody) + debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) elseif netData.event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.reLoadFileBody = netData.data LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) LuaDebugger.reLoadFileBody.script = nil - + debugger_sendMsg( breakInfoSocket, LuaDebugger.event.C2S_ReLoadFile, { stack = LuaDebugger.reLoadFileBody - + } - ) - end - end - end + ) + end + end + end end local function splitFilePath(path) - if (LuaDebugger.splitFilePaths[path]) then - return LuaDebugger.splitFilePaths[path] - end - local pos, arr = 0, {} - -- for each divider found - for st, sp in function() + if (LuaDebugger.splitFilePaths[path]) then + return LuaDebugger.splitFilePaths[path] + end + local pos, arr = 0, {} + -- for each divider found + for st, sp in function() return string.find(path, "/", pos, true) - end do - local pathStr = string.sub(path, pos, st - 1) - table.insert(arr, pathStr) - pos = sp + 1 - end - local pathStr = string.sub(path, pos) - table.insert(arr, pathStr) - LuaDebugger.splitFilePaths[path] = arr - return arr -end -debugger_setBreak = - function(datas) - local breakInfos = LuaDebugger.breakInfos - for i, data in ipairs(datas) do - data.fileName = string.lower(data.fileName) - data.serverPath = string.lower(data.serverPath) - local breakInfo = breakInfos[data.fileName] - if (not breakInfo) then - breakInfos[data.fileName] = {} - breakInfo = breakInfos[data.fileName] - end - if (not data.breakDatas or #data.breakDatas == 0) then - breakInfo[data.serverPath] = nil - else - local fileBreakInfo = breakInfo[data.serverPath] - if (not fileBreakInfo) then - fileBreakInfo = { - pathNames = splitFilePath(data.serverPath), - --命中次數判斷計數器 - hitCounts = {} - } - breakInfo[data.serverPath] = fileBreakInfo - end - local lineInfos = {} - for li, breakData in ipairs(data.breakDatas) do - lineInfos[breakData.line] = breakData - if (breakData.hitCondition and breakData.hitCondition ~= "") then - breakData.hitCondition = tonumber(breakData.hitCondition) - else - breakData.hitCondition = 0 - end - if (not fileBreakInfo.hitCounts[breakData.line]) then - fileBreakInfo.hitCounts[breakData.line] = 0 - end - end - fileBreakInfo.lines = lineInfos - --這裡添加命中次數判斷 - for line, count in pairs(fileBreakInfo.hitCounts) do - if (not lineInfos[line]) then - fileBreakInfo.hitCounts[line] = nil - end - end - end - local count = 0 - for i, linesInfo in pairs(breakInfo) do - count = count + 1 - end - if (count == 0) then - breakInfos[data.fileName] = nil - end - end - --debugger_dump(breakInfos, "breakInfos", 6) - --检查是否需要断点 - local isHook = false - for k, v in pairs(breakInfos) do - isHook = true - break - end - - --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 - if (isHook) then - if (not LuaDebugger.isHook) then - debug.sethook(debug_hook, "lrc") - end - LuaDebugger.isHook = true - else - if (LuaDebugger.isHook) then - debug.sethook() - end - LuaDebugger.isHook = false - end + end do + local pathStr = string.sub(path, pos, st - 1) + table.insert(arr, pathStr) + pos = sp + 1 + end + local pathStr = string.sub(path, pos) + table.insert(arr, pathStr) + LuaDebugger.splitFilePaths[path] = arr + return arr end +debugger_setBreak = + function(datas) + local breakInfos = LuaDebugger.breakInfos + for i, data in ipairs(datas) do + data.fileName = string.lower(data.fileName) + data.serverPath = string.lower(data.serverPath) + local breakInfo = breakInfos[data.fileName] + if (not breakInfo) then + breakInfos[data.fileName] = {} + breakInfo = breakInfos[data.fileName] + end + if (not data.breakDatas or #data.breakDatas == 0) then + breakInfo[data.serverPath] = nil + else + local fileBreakInfo = breakInfo[data.serverPath] + if (not fileBreakInfo) then + fileBreakInfo = { + pathNames = splitFilePath(data.serverPath), + --命中次數判斷計數器 + hitCounts = {} + } + breakInfo[data.serverPath] = fileBreakInfo + end + local lineInfos = {} + for li, breakData in ipairs(data.breakDatas) do + lineInfos[breakData.line] = breakData + if (breakData.hitCondition and breakData.hitCondition ~= "") then + breakData.hitCondition = tonumber(breakData.hitCondition) + else + breakData.hitCondition = 0 + end + if (not fileBreakInfo.hitCounts[breakData.line]) then + fileBreakInfo.hitCounts[breakData.line] = 0 + end + end + fileBreakInfo.lines = lineInfos + --這裡添加命中次數判斷 + for line, count in pairs(fileBreakInfo.hitCounts) do + if (not lineInfos[line]) then + fileBreakInfo.hitCounts[line] = nil + end + end + end + local count = 0 + for i, linesInfo in pairs(breakInfo) do + count = count + 1 + end + if (count == 0) then + breakInfos[data.fileName] = nil + end + end + --debugger_dump(breakInfos, "breakInfos", 6) + --检查是否需要断点 + local isHook = false + for k, v in pairs(breakInfos) do + isHook = true + break + end + + --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 + if (isHook) then + if (not LuaDebugger.isHook) then + debug.sethook(debug_hook, "lrc") + end + LuaDebugger.isHook = true + else + if (LuaDebugger.isHook) then + debug.sethook() + end + LuaDebugger.isHook = false + end + end local function debugger_checkFileIsBreak(fileName) - return LuaDebugger.breakInfos[fileName] + return LuaDebugger.breakInfos[fileName] end --=====================================断点信息 end ---------------------------------------------- local controller_host = "192.168.1.102" local controller_port = 7003 debugger_sendMsg = function(serverSocket, eventName, data) - local sendMsg = { - event = eventName, - data = data - } - local sendStr = json.encode(sendMsg) - serverSocket:send(sendStr .. "__debugger_k0204__") + local sendMsg = { + event = eventName, + data = data + } + local sendStr = json.encode(sendMsg) + serverSocket:send(sendStr .. "__debugger_k0204__") end -function debugger_conditionStr(condition, vars, callBack) - local function loadScript() - local currentTabble = {} - - local locals = vars[1].locals - local ups = vars[1].ups - if (ups) then - for k, v in pairs(ups) do - currentTabble[k] = v - end - end - - if (locals) then - for k, v in pairs(locals) do - currentTabble[k] = v - end - end - setmetatable(currentTabble, {__index = _G}) - local fun = loadstring("return " .. condition) - setfenv(fun, currentTabble) - return fun() - end - local status, - msg = - xpcall( - loadScript, - function(error) - print(error) +function debugger_conditionStr(condition, vars, callBack) + local function loadScript() + local currentTabble = {} + + local locals = vars[1].locals + local ups = vars[1].ups + if (ups) then + for k, v in pairs(ups) do + currentTabble[k] = v + end end - ) + + if (locals) then + for k, v in pairs(locals) do + currentTabble[k] = v + end + end + setmetatable(currentTabble, { __index = _G }) + local fun = loadstring("return " .. condition) + setfenv(fun, currentTabble) + return fun() + end + local status, + msg = + xpcall( + loadScript, + function(error) + -- print(error) + end + ) if (status and msg) then callBack() end end + --执行lua字符串 debugger_exeLuaString = function() - local function loadScript() - local script = LuaDebugger.loadScriptBody.script if (LuaDebugger.loadScriptBody.isBreak) then - local currentTabble = {_G = _G} + local currentTabble = { _G = _G } local frameId = LuaDebugger.loadScriptBody.frameId frameId = frameId local func = LuaDebugger.currentDebuggerData.funcs[frameId] @@ -1336,8 +1335,8 @@ debugger_exeLuaString = function() for k, v in pairs(locals) do currentTabble[k] = v end - setmetatable(currentTabble, {__index = _G}) - + setmetatable(currentTabble, { __index = _G }) + local fun = loadstring(script) setfenv(fun, currentTabble) fun() @@ -1347,54 +1346,51 @@ debugger_exeLuaString = function() end end local status, - msg = + msg = xpcall( - loadScript, - function(error) - - -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) - end - ) - LuaDebugger.loadScriptBody.script = nil + loadScript, + function(error) + -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) + end + ) + LuaDebugger.loadScriptBody.script = nil if (LuaDebugger.loadScriptBody.isBreak) then - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack - end + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event + .C2S_HITBreakPoint) + LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack + end LuaDebugger.loadScriptBody.complete = true - end --@region 调试中修改变量值 --根据key 值在 value 查找 -local function debugger_getTablekey(key,keyType,value) - if(keyType == -1) then +local function debugger_getTablekey(key, keyType, value) + if (keyType == -1) then return key - elseif(keyType == 1) then + elseif (keyType == 1) then return tonumber(key) - elseif(keyType == 2) then + elseif (keyType == 2) then local valueKey = nil - for k,v in pairs(value) do + for k, v in pairs(value) do local nameType = type(k) - if(nameType == "userdata" or nameType == "table") then + if (nameType == "userdata" or nameType == "table") then if (not LuaDebugger.isFoxGloryProject) then valueKey = tostring(k) - if(key == valueKey) then + if (key == valueKey) then return k end break end end end - end end local function debugger_setVarValue(server, data) - local newValue = nil - local level = LuaDebugger.serVarLevel+LuaDebugger.setVarBody.frameId + local level = LuaDebugger.serVarLevel + LuaDebugger.setVarBody.frameId local firstKeyName = data.keys[1] --@region vars check local localValueChangeIndex = -1 @@ -1409,7 +1405,7 @@ local function debugger_setVarValue(server, data) if not name then break end - if(firstKeyName == name) then + if (firstKeyName == name) then localValueChangeIndex = i oldValue = value end @@ -1423,11 +1419,11 @@ local function debugger_setVarValue(server, data) local ups = {} while func do -- check for func as it may be nil for tail calls local name, value = debug.getupvalue(func, i) - + if not name then break end - if(localValueChangeIndex == -1 and firstKeyName == name) then + if (localValueChangeIndex == -1 and firstKeyName == name) then upValueFun = func oldValue = value upValueChangeIndex = i @@ -1439,9 +1435,9 @@ local function debugger_setVarValue(server, data) end i = i + 1 end ---@endregion - local vars = {locals = locals, ups = ups} - + --@endregion + local vars = { locals = locals, ups = ups } + local function loadScript() local currentTabble = {} local locals = vars.locals @@ -1457,58 +1453,56 @@ local function debugger_setVarValue(server, data) currentTabble[k] = v end end - setmetatable(currentTabble, {__index = _G}) + setmetatable(currentTabble, { __index = _G }) local fun = loadstring("return " .. data.value) setfenv(fun, currentTabble) newValue = fun() end local status, - msg = + msg = xpcall( - loadScript, - function(error) - print(error, "============================") - end - ) - + loadScript, + function(error) + -- print(error, "============================") + end + ) + local i = 1 - + -- local 查找并替换 local keyLength = #data.keys - - if(keyLength == 1) then - if(localValueChangeIndex ~= -1) then - + + if (keyLength == 1) then + if (localValueChangeIndex ~= -1) then debug.setlocal(level, localValueChangeIndex, newValue) - elseif(upValueFun ~= nil) then - debug.setupvalue( upValueFun, upValueChangeIndex, newValue ) + elseif (upValueFun ~= nil) then + debug.setupvalue(upValueFun, upValueChangeIndex, newValue) else --全局变量查找 - if(_G[firstKeyName]) then + if (_G[firstKeyName]) then _G[firstKeyName] = newValue end end else - if(not oldValue) then - if(_G[firstKeyName]) then + if (not oldValue) then + if (_G[firstKeyName]) then oldValue = _G[firstKeyName] end end local tempValue = oldValue - for i=2,keyLength-1 do - if(tempValue) then - oldValue = oldValue[debugger_getTablekey(data.keys[i],data.numberTypes[i],oldValue)] + for i = 2, keyLength - 1 do + if (tempValue) then + oldValue = oldValue[debugger_getTablekey(data.keys[i], data.numberTypes[i], oldValue)] end end - if(tempValue) then - oldValue[debugger_getTablekey(data.keys[keyLength],data.numberTypes[keyLength],oldValue)] = newValue + if (tempValue) then + oldValue[debugger_getTablekey(data.keys[keyLength], data.numberTypes[keyLength], oldValue)] = newValue end end - local varInfo = debugger_setVarInfo(data.varName, newValue) + local varInfo = debugger_setVarInfo(data.varName, newValue) data.varInfo = varInfo - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) - end --@endregion @@ -1518,107 +1512,107 @@ end --调试修改变量值统一的 _resume checkSetVar = function() - if (LuaDebugger.isSetVar) then - LuaDebugger.isSetVar = false - debugger_setVarValue(debug_server,LuaDebugger.setVarBody) - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.setVarBody) - xpcall( - checkSetVar, - function(error) - print("设置变量", error) - end - ) - elseif(LuaDebugger.isLoadLuaScript) then - LuaDebugger.isLoadLuaScript = false - debugger_exeLuaString() - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("执行代码", error) - end - ) - elseif(LuaDebugger.isReLoadFile) then - LuaDebugger.isReLoadFile = false - LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) - print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) - LuaDebugger.reLoadFileBody.script = nil - LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 - _resume(coro_debugger, LuaDebugger.reLoadFileBody) - xpcall( - checkSetVar, - function(error) - print("重新加载文件", error) - end - ) + if (LuaDebugger.isSetVar) then + LuaDebugger.isSetVar = false + debugger_setVarValue(debug_server, LuaDebugger.setVarBody) + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.setVarBody) + xpcall( + checkSetVar, + function(error) + -- print("设置变量", error) + end + ) + elseif (LuaDebugger.isLoadLuaScript) then + LuaDebugger.isLoadLuaScript = false + debugger_exeLuaString() + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("执行代码", error) + end + ) + elseif (LuaDebugger.isReLoadFile) then + LuaDebugger.isReLoadFile = false + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + -- print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.script = nil + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel + 1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + -- print("重新加载文件", error) + end + ) + end end -end - + local function getSource(source) - source = string.lower(source) + source = string.lower(source) if (LuaDebugger.pathCachePaths[source]) then - LuaDebugger.currentLineFile = LuaDebugger.pathCachePaths[source] - return LuaDebugger.pathCachePaths[source] - end + LuaDebugger.currentLineFile = LuaDebugger.pathCachePaths[source] + return LuaDebugger.pathCachePaths[source] + end - local fullName, dir, fileName = debugger_getFilePathInfo(source) - LuaDebugger.currentLineFile = fullName - LuaDebugger.pathCachePaths[source] = fileName + local fullName, dir, fileName = debugger_getFilePathInfo(source) + LuaDebugger.currentLineFile = fullName + LuaDebugger.pathCachePaths[source] = fileName - return fileName + return fileName end local function debugger_GeVarInfoBytUserData(server, var) - local fileds = LuaDebugTool.getUserDataInfo(var) - - local varInfos = {} + local fileds = LuaDebugTool.getUserDataInfo(var) - - --c# vars - for i = 1, fileds.Count do - local filed = fileds[i - 1] - local valueInfo = { - name = filed.name, - valueType = filed.valueType, - valueStr = ZZBase64.encode(filed.valueStr), - isValue = filed.isValue, - csharp = true - } - - table.insert(varInfos, valueInfo) - end - return varInfos -end + local varInfos = {} + + + --c# vars + for i = 1, fileds.Count do + local filed = fileds[i - 1] + local valueInfo = { + name = filed.name, + valueType = filed.valueType, + valueStr = ZZBase64.encode(filed.valueStr), + isValue = filed.isValue, + csharp = true + } + + table.insert(varInfos, valueInfo) + end + return varInfos +end local function debugger_getValueByScript(value, script) - local val = nil - local status, - msg = - xpcall( - function() - local fun = loadstring("return " .. script) - setfenv(fun, value) - val = fun() - end, - function(error) - print(error, "====>") - val = nil - end - ) + local val = nil + local status, + msg = + xpcall( + function() + local fun = loadstring("return " .. script) + setfenv(fun, value) + val = fun() + end, + function(error) + -- print(error, "====>") + val = nil + end + ) - return val + return val end -local function debugger_getVarByKeys(value, keys, index) - local str = "" - local keyLength = #keys - for i = index, keyLength do - local key = keys[i] - if (key == "[metatable]") then - else - if (i == index) then +local function debugger_getVarByKeys(value, keys, index) + local str = "" + local keyLength = #keys + for i = index, keyLength do + local key = keys[i] + if (key == "[metatable]") then + else + if (i == index) then if (string.find(key, "%.")) then if (str == "") then i = index + 1 @@ -1630,10 +1624,10 @@ local function debugger_getVarByKeys(value, keys, index) return debugger_getVarByKeys(value, keys, i) else - str = key - end - else - if (string.find(key, "%[")) then + str = key + end + else + if (string.find(key, "%[")) then str = str .. key elseif (type(key) == "string") then if (string.find(key, "table:") or string.find(key, "userdata:") or string.find(key, "function:")) then @@ -1712,7 +1706,7 @@ end local function debugger_searchVarByKeys(value, keys, searckKeys) local index, val = debugger_getVarByKeys(value, searckKeys, 1) - if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then + if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then return index, val end if (val) then @@ -1745,7 +1739,6 @@ end return ]] local function debugger_getmetatable(value, metatable, vinfos, server, variablesReference, debugSpeedIndex, metatables) - for i, mtable in ipairs(metatables) do if (metatable == mtable) then return vinfos @@ -1794,14 +1787,13 @@ local function debugger_getmetatable(value, metatable, vinfos, server, variables end end end - + local m = getmetatable(metatable) if (m) then return debugger_getmetatable(value, m, vinfos, server, variablesReference, debugSpeedIndex, metatables) else return vinfos end - end local function debugger_sendTableField(luatable, vinfos, server, variablesReference, debugSpeedIndex, valueType) if (valueType == "userdata") then @@ -1840,12 +1832,12 @@ local function debugger_sendTableValues(value, server, variablesReference, debug local valueType = type(value) local userDataInfos = {} local m = nil - + if (valueType == "userdata") then m = getmetatable(value) - + vinfos = debugger_sendTableField(value, vinfos, server, variablesReference, debugSpeedIndex, valueType) - + if (LuaDebugTool) then local varInfos = debugger_GeVarInfoBytUserData(server, value, variablesReference, debugSpeedIndex) @@ -1874,7 +1866,6 @@ local function debugger_sendTableValues(value, server, variablesReference, debug vinfos = {} end end - end else m = getmetatable(value) @@ -1898,56 +1889,55 @@ end --获取lua 变量的方法 local function debugger_getBreakVar(body, server) - local variablesReference = body.variablesReference - local debugSpeedIndex = body.debugSpeedIndex - local vinfos = {} - local function exe() - local frameId = body.frameId + local variablesReference = body.variablesReference + local debugSpeedIndex = body.debugSpeedIndex + local vinfos = {} + local function exe() + local frameId = body.frameId local type_ = body.type local keys = body.keys - --找到对应的var - local vars = nil - if (type_ == 1) then - vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] - vars = vars.locals - elseif (type_ == 2) then - vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] - vars = vars.ups - elseif (type_ == 3) then - vars = _G - end - if (#keys == 0) then - debugger_sendTableValues(vars, server, variablesReference, debugSpeedIndex) - return - end - local index, value = debugger_searchVarByKeys(vars, keys, keys) - if (value) then - local valueType = type(value) + --找到对应的var + local vars = nil + if (type_ == 1) then + vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] + vars = vars.locals + elseif (type_ == 2) then + vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] + vars = vars.ups + elseif (type_ == 3) then + vars = _G + end + if (#keys == 0) then + debugger_sendTableValues(vars, server, variablesReference, debugSpeedIndex) + return + end + local index, value = debugger_searchVarByKeys(vars, keys, keys) + if (value) then + local valueType = type(value) if (valueType == "table" or valueType == "userdata") then - - debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) - else + debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) + else if (valueType == "function") then - if(LuaDebugger.isFoxGloryProject) then - value = "function" + if (LuaDebugger.isFoxGloryProject) then + value = "function" else value = tostring(value) end - end - debugger_sendMsg( + end + debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, { - variablesReference = variablesReference, - debugSpeedIndex = debugSpeedIndex, - vars = ZZBase64.encode(value), - isComplete = 1, - varType = valueType - } + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = ZZBase64.encode(value), + isComplete = 1, + varType = valueType + } ) - end - else - debugger_sendMsg( + end + else + debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, { @@ -1958,14 +1948,14 @@ local function debugger_getBreakVar(body, server) varType = "nil" } ) - end - end - xpcall( + end + end + xpcall( exe, function(error) - -- print("获取变量错误 错误消息-----------------") - -- print(error) - -- print(debug.traceback("", 2)) + -- -- print("获取变量错误 错误消息-----------------") + -- -- print(error) + -- -- print(debug.traceback("", 2)) debugger_sendMsg( server, LuaDebugger.event.C2S_ReqVar, @@ -1987,64 +1977,62 @@ local function debugger_getBreakVar(body, server) ) end local function ResetDebugInfo() - LuaDebugger.Run = false - LuaDebugger.StepIn = false - LuaDebugger.StepNext = false - LuaDebugger.StepOut = false - + LuaDebugger.Run = false + LuaDebugger.StepIn = false + LuaDebugger.StepNext = false + LuaDebugger.StepOut = false end local function debugger_loop(server) - server = debug_server - --命令 - local command - local eval_env = {} - local arg - while true do - local line, status = server:receive() - if (status == "closed") then - if(LuaDebugger.isLaunch) then + server = debug_server + --命令 + local command + local eval_env = {} + local arg + while true do + local line, status = server:receive() + if (status == "closed") then + if (LuaDebugger.isLaunch) then os.exit() else debug.sethook() coroutine.yield() end - end - if (line) then - local netData = json.decode(line) - local event = netData.event + end + if (line) then + local netData = json.decode(line) + local event = netData.event local body = netData.data if (event == LuaDebugger.event.S2C_DebugClose) then - if(LuaDebugger.isLaunch) then - os.exit() - else - debug.sethook() - coroutine.yield() - end - - elseif event == LuaDebugger.event.S2C_SetBreakPoints then - --设置断点信息 - local function setB() - debugger_setBreak(body) - end - xpcall( + if (LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end + elseif event == LuaDebugger.event.S2C_SetBreakPoints then + --设置断点信息 + local function setB() + debugger_setBreak(body) + end + xpcall( setB, function(error) - print(error) + -- print(error) end ) - elseif event == LuaDebugger.event.S2C_RUN then --开始运行 - LuaDebugger.runTimeType = body.runTimeType - LuaDebugger.isProntToConsole = body.isProntToConsole + elseif event == LuaDebugger.event.S2C_RUN then --开始运行 + LuaDebugger.runTimeType = body.runTimeType + LuaDebugger.isProntToConsole = body.isProntToConsole LuaDebugger.isFoxGloryProject = body.isFoxGloryProject LuaDebugger.isLaunch = body.isLaunch - ResetDebugInfo() - LuaDebugger.currentDebuggerData = nil - LuaDebugger.Run = true + ResetDebugInfo() + LuaDebugger.currentDebuggerData = nil + LuaDebugger.Run = true LuaDebugger.tempRunFlag = true - LuaDebugger.currentLine= nil - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - LuaDebugger.currentDebuggerData = data + LuaDebugger.currentLine = nil + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + LuaDebugger.currentDebuggerData = data debugger_sendMsg( server, data.event, @@ -2052,58 +2040,58 @@ local function debugger_loop(server) stack = data.stack } ) - elseif event == LuaDebugger.event.S2C_ReqVar then -- 获取变量信息 - --请求数据信息 - debugger_getBreakVar(body, server) - elseif event == LuaDebugger.event.S2C_NextRequest then -- 设置单步跳过 - ResetDebugInfo() - LuaDebugger.StepNext = true - --设置当前文件名和当前行数 - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - --重置调试信息 - LuaDebugger.currentDebuggerData = data - debugger_sendMsg( + elseif event == LuaDebugger.event.S2C_ReqVar then -- 获取变量信息 + --请求数据信息 + debugger_getBreakVar(body, server) + elseif event == LuaDebugger.event.S2C_NextRequest then -- 设置单步跳过 + ResetDebugInfo() + LuaDebugger.StepNext = true + --设置当前文件名和当前行数 + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( server, data.event, { stack = data.stack } ) - elseif (event == LuaDebugger.event.S2C_StepInRequest) then --单步跳入 - --单步跳入 - ResetDebugInfo() - LuaDebugger.StepIn = true - - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - --重置调试信息 - LuaDebugger.currentDebuggerData = data - debugger_sendMsg( + elseif (event == LuaDebugger.event.S2C_StepInRequest) then --单步跳入 + --单步跳入 + ResetDebugInfo() + LuaDebugger.StepIn = true + + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( server, data.event, { - stack = data.stack, - eventType = data.eventType - } - ) - elseif (event == LuaDebugger.event.S2C_StepOutRequest) then - --单步跳出 - ResetDebugInfo() - LuaDebugger.StepOut = true - local data = coroutine.yield() - LuaDebugger.serVarLevel = 4 - --重置调试信息 - LuaDebugger.currentDebuggerData = data - debugger_sendMsg( + stack = data.stack, + eventType = data.eventType + } + ) + elseif (event == LuaDebugger.event.S2C_StepOutRequest) then + --单步跳出 + ResetDebugInfo() + LuaDebugger.StepOut = true + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( server, data.event, { - stack = data.stack, - eventType = data.eventType - } - ) - elseif event == LuaDebugger.event.S2C_LoadLuaScript then + stack = data.stack, + eventType = data.eventType + } + ) + elseif event == LuaDebugger.event.S2C_LoadLuaScript then LuaDebugger.loadScriptBody = body LuaDebugger.isLoadLuaScript = true local data = coroutine.yield() @@ -2123,8 +2111,8 @@ local function debugger_loop(server) stack = data, eventType = data.eventType } - ) - elseif event == LuaDebugger.event.S2C_ReLoadFile then + ) + elseif event == LuaDebugger.event.S2C_ReLoadFile then LuaDebugger.isReLoadFile = true LuaDebugger.reLoadFileBody = body local data = coroutine.yield() @@ -2135,340 +2123,321 @@ local function debugger_loop(server) stack = data, eventType = data.eventType } - ) - end - end - end + ) + end + end + end end coro_debugger = coroutine.create(debugger_loop) debug_hook = function(event, line) + if (not LuaDebugger.isHook) then + return + end - if(not LuaDebugger.isHook) then - return - end + if (LuaDebugger.Run) then + if (event == "line") then + local isCheck = false + for k, breakInfo in pairs(LuaDebugger.breakInfos) do + for bk, linesInfo in pairs(breakInfo) do + if (linesInfo.lines and linesInfo.lines[line]) then + isCheck = true + break + end + end + if (isCheck) then + break + end + end - if(LuaDebugger.Run) then - if(event == "line") then - local isCheck = false - for k, breakInfo in pairs(LuaDebugger.breakInfos) do + if (not isCheck) then + return + end + end + end - for bk, linesInfo in pairs(breakInfo) do - - if(linesInfo.lines and linesInfo.lines[line]) then - isCheck = true - break - end - end - if(isCheck) then - break - end - end - - if(not isCheck) then - return - end - - end - end - - - local file = nil - if(event == "line") then - - local funs = nil - local funlength =0 - if(LuaDebugger.currentDebuggerData) then - funs = LuaDebugger.currentDebuggerData.funcs - funlength = #funs - end - local stepInfo = getinfo(2) - local tempFunc = stepInfo.func - local source = stepInfo.source - file = getSource(source); - if(source == "=[C]" or source:find(LuaDebugger.DebugLuaFie)) then return end - if(funlength > 0 and funs[1] == tempFunc and LuaDebugger.currentLine ~= line) then - LuaDebugger.runLineCount = LuaDebugger.runLineCount+1 - end - local breakInfo = LuaDebugger.breakInfos[file] - local breakData = nil - local ischeck = false - if(breakInfo) then - - for k, lineInfo in pairs(breakInfo) do - local lines = lineInfo.lines - if(lines and lines[line]) then - ischeck = true - break - end - end - end - local isHit = false - if(ischeck) then - - --并且在断点中 - local info = stepInfo - local source = string.lower( info.source ) - local fullName,dir,fileName = debugger_getFilePathInfo(source) - local hitPathNames = splitFilePath(fullName) - - local hitCounts = {} - local debugHitCounts = nil - for k, lineInfo in pairs(breakInfo) do + local file = nil + if (event == "line") then + local funs = nil + local funlength = 0 + if (LuaDebugger.currentDebuggerData) then + funs = LuaDebugger.currentDebuggerData.funcs + funlength = #funs + end + local stepInfo = getinfo(2) + local tempFunc = stepInfo.func + local source = stepInfo.source + file = getSource(source); + if (source == "=[C]" or source:find(LuaDebugger.DebugLuaFie)) then return end + if (funlength > 0 and funs[1] == tempFunc and LuaDebugger.currentLine ~= line) then + LuaDebugger.runLineCount = LuaDebugger.runLineCount + 1 + end + local breakInfo = LuaDebugger.breakInfos[file] + local breakData = nil + local ischeck = false + if (breakInfo) then + for k, lineInfo in pairs(breakInfo) do local lines = lineInfo.lines - local pathNames = lineInfo.pathNames - debugHitCounts = lineInfo.hitCounts - if(lines and lines[line]) then - breakData = lines[line] - --判断路径 - hitCounts[k] = 0 - local hitPathNamesCount = #hitPathNames - local pathNamesCount = #pathNames - local checkCount = 0; - while(true) do - if (pathNames[pathNamesCount] ~= hitPathNames[hitPathNamesCount]) then - break - else - hitCounts[k] = hitCounts[k] + 1 - end - pathNamesCount = pathNamesCount - 1 - hitPathNamesCount = hitPathNamesCount - 1 - checkCount = checkCount+1 - if(pathNamesCount <= 0 or hitPathNamesCount <= 0) then - break - end - end - if(checkCount>0) then - break; - end - else - breakData = nil - end - end - if(breakData) then - local hitFieName = "" - local maxCount = 0 - for k, v in pairs(hitCounts) do - if(v > maxCount) then - maxCount = v - hitFieName = k; - end - end - local hitPathNamesLength = #hitPathNames - if (hitPathNamesLength == 1 or (hitPathNamesLength > 1 and maxCount > 1)) then - if(hitFieName ~= "") then + if (lines and lines[line]) then + ischeck = true + break + end + end + end + local isHit = false + if (ischeck) then + --并且在断点中 + local info = stepInfo + local source = string.lower(info.source) + local fullName, dir, fileName = debugger_getFilePathInfo(source) + local hitPathNames = splitFilePath(fullName) + local hitCounts = {} + local debugHitCounts = nil + for k, lineInfo in pairs(breakInfo) do + local lines = lineInfo.lines + local pathNames = lineInfo.pathNames + debugHitCounts = lineInfo.hitCounts + if (lines and lines[line]) then + breakData = lines[line] + --判断路径 + hitCounts[k] = 0 + local hitPathNamesCount = #hitPathNames + local pathNamesCount = #pathNames + local checkCount = 0; + while (true) do + if (pathNames[pathNamesCount] ~= hitPathNames[hitPathNamesCount]) then + break + else + hitCounts[k] = hitCounts[k] + 1 + end + pathNamesCount = pathNamesCount - 1 + hitPathNamesCount = hitPathNamesCount - 1 + checkCount = checkCount + 1 + if (pathNamesCount <= 0 or hitPathNamesCount <= 0) then + break + end + end + if (checkCount > 0) then + break; + end + else + breakData = nil + end + end + if (breakData) then + local hitFieName = "" + local maxCount = 0 + for k, v in pairs(hitCounts) do + if (v > maxCount) then + maxCount = v + hitFieName = k; + end + end + local hitPathNamesLength = #hitPathNames + if (hitPathNamesLength == 1 or (hitPathNamesLength > 1 and maxCount > 1)) then + if (hitFieName ~= "") then local hitCount = breakData.hitCondition - local clientHitCount = debugHitCounts[breakData.line] - clientHitCount = clientHitCount + 1 - debugHitCounts[breakData.line] = clientHitCount - if(funs and funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then - LuaDebugger.runLineCount = 0 - elseif(LuaDebugger.tempRunFlag and LuaDebugger.currentLine == line) then - LuaDebugger.runLineCount = 0 - LuaDebugger.tempRunFlag = nil - elseif(clientHitCount >= hitCount) then - isHit = true - end - - end - end - end - end - if(LuaDebugger.StepOut) then - if(funlength == 1) then - ResetDebugInfo(); - LuaDebugger.Run = true - return - else - if(funs[2] == tempFunc) then - local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) - -- print("StepIn 挂起") - --挂起等待调试器作出反应 + local clientHitCount = debugHitCounts[breakData.line] + clientHitCount = clientHitCount + 1 + debugHitCounts[breakData.line] = clientHitCount + if (funs and funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then + LuaDebugger.runLineCount = 0 + elseif (LuaDebugger.tempRunFlag and LuaDebugger.currentLine == line) then + LuaDebugger.runLineCount = 0 + LuaDebugger.tempRunFlag = nil + elseif (clientHitCount >= hitCount) then + isHit = true + end + end + end + end + end + if (LuaDebugger.StepOut) then + if (funlength == 1) then + ResetDebugInfo(); + LuaDebugger.Run = true + return + else + if (funs[2] == tempFunc) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) + -- -- print("StepIn 挂起") + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - return - end - end - end - - if(LuaDebugger.StepIn) then - if(funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then - return - end - local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) - -- print("StepIn 挂起") - --挂起等待调试器作出反应 + return + end + end + end + + if (LuaDebugger.StepIn) then + if (funs[1] == tempFunc and LuaDebugger.runLineCount == 0) then + return + end + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) + -- -- print("StepIn 挂起") + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - return - end - - if(LuaDebugger.StepNext ) then - local isNext = false - if(funs) then - for i,f in ipairs(funs) do - if(tempFunc == f) then - if(LuaDebugger.currentLine == line) then - return - end - isNext =true - break; - end - end + return + end + + if (LuaDebugger.StepNext) then + local isNext = false + if (funs) then + for i, f in ipairs(funs) do + if (tempFunc == f) then + if (LuaDebugger.currentLine == line) then + return + end + isNext = true + break; + end + end else - - isNext =true - end - if(isNext) then - local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) - LuaDebugger.runLineCount = 0 - LuaDebugger.currentLine = line - --挂起等待调试器作出反应 + isNext = true + end + if (isNext) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) + LuaDebugger.runLineCount = 0 + LuaDebugger.currentLine = line + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - return - end - end - - local sevent = nil - + return + end + end - --断点判断 - if(isHit) then - + local sevent = nil - LuaDebugger.runLineCount = 0 - LuaDebugger.currentLine = line - sevent = LuaDebugger.event.C2S_HITBreakPoint - --调用 coro_debugger 并传入 参数 - local data = debugger_stackInfo(3, sevent) - --挂起等待调试器作出反应 - if(breakData and breakData.condition) then - debugger_conditionStr(breakData.condition,data.vars,function() + + --断点判断 + if (isHit) then + LuaDebugger.runLineCount = 0 + LuaDebugger.currentLine = line + sevent = LuaDebugger.event.C2S_HITBreakPoint + --调用 coro_debugger 并传入 参数 + local data = debugger_stackInfo(3, sevent) + --挂起等待调试器作出反应 + if (breakData and breakData.condition) then + debugger_conditionStr(breakData.condition, data.vars, function() _resume(coro_debugger, data) checkSetVar() - end) - else - --挂起等待调试器作出反应 + end) + else + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() - end - end - end + end + end + end end local function debugger_xpcall() - --调用 coro_debugger 并传入 参数 + --调用 coro_debugger 并传入 参数 local data = debugger_stackInfo(4, LuaDebugger.event.C2S_HITBreakPoint) - if(data.stack and data.stack[1]) then - data.stack[1].isXpCall = true + if (data.stack and data.stack[1]) then + data.stack[1].isXpCall = true end - --挂起等待调试器作出反应 + --挂起等待调试器作出反应 _resume(coro_debugger, data) checkSetVar() end --调试开始 local function start() - - local socket = createSocket() - print(controller_host) - print(controller_port) - - local fullName,dirName,fileName = debugger_getFilePathInfo(getinfo(1).source) - LuaDebugger.DebugLuaFie = fileName - local server = socket.connect(controller_host, controller_port) - debug_server = server; - if server then - --创建breakInfo socket - socket = createSocket() - breakInfoSocket = socket.connect(controller_host, controller_port) - if(breakInfoSocket) then - breakInfoSocket:settimeout(0) - debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_SetSocketName, { - name = "breakPointSocket" - }) - - - debugger_sendMsg(server, LuaDebugger.event.C2S_SetSocketName, { - name = "mainSocket", - version = LuaDebugger.version + local socket = createSocket() + -- print(controller_host) + -- print(controller_port) - }) - xpcall(function() - sethook(debug_hook, "lrc") - end, function(error) - print("error:", error) - end) - if(not jit) then - if(_VERSION)then - print("当前lua版本为: ".._VERSION.." 请使用LuaDebug 进行调试!") - else - print("当前为lua版本,请使用LuaDebug 进行调试!") - end - - end - _resume(coro_debugger, server) - end - end + local fullName, dirName, fileName = debugger_getFilePathInfo(getinfo(1).source) + LuaDebugger.DebugLuaFie = fileName + local server = socket.connect(controller_host, controller_port) + debug_server = server; + if server then + --创建breakInfo socket + socket = createSocket() + breakInfoSocket = socket.connect(controller_host, controller_port) + if (breakInfoSocket) then + breakInfoSocket:settimeout(0) + debugger_sendMsg(breakInfoSocket, LuaDebugger.event.C2S_SetSocketName, { + name = "breakPointSocket" + }) + + + debugger_sendMsg(server, LuaDebugger.event.C2S_SetSocketName, { + name = "mainSocket", + version = LuaDebugger.version + + }) + xpcall(function() + sethook(debug_hook, "lrc") + end, function(error) + -- print("error:", error) + end) + if (not jit) then + if (_VERSION) then + -- print("当前lua版本为: ".._VERSION.." 请使用LuaDebug 进行调试!") + else + -- print("当前为lua版本,请使用LuaDebug 进行调试!") + end + end + _resume(coro_debugger, server) + end + end end function StartDebug(host, port) - - - if(not host) then - print("error host nil") - end - if(not port) then - print("error prot nil") - end - if(type(host) ~= "string") then - print("error host not string") - end - if(type(port) ~= "number") then - print("error host not number") - end - controller_host = host - controller_port = port - xpcall(start, function(error) - -- body - print(error) - end) - return debugger_receiveDebugBreakInfo, debugger_xpcall + if (not host) then + -- print("error host nil") + end + if (not port) then + -- print("error prot nil") + end + if (type(host) ~= "string") then + -- print("error host not string") + end + if (type(port) ~= "number") then + -- print("error host not number") + end + controller_host = host + controller_port = port + xpcall(start, function(error) + -- body + -- print(error) + end) + return debugger_receiveDebugBreakInfo, debugger_xpcall end - - --base64 local string = string ZZBase64.__code = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', - }; + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', +}; ZZBase64.__decode = {} -for k,v in pairs(ZZBase64.__code) do - ZZBase64.__decode[string.byte(v,1)] = k - 1 +for k, v in pairs(ZZBase64.__code) do + ZZBase64.__decode[string.byte(v, 1)] = k - 1 end function ZZBase64.encode(text) - local len = string.len(text) - local left = len % 3 - len = len - left - local res = {} - local index = 1 + local len = string.len(text) + local left = len % 3 + len = len - left + local res = {} + local index = 1 for i = 1, len, 3 do - local a = string.byte(text, i ) + local a = string.byte(text, i) local b = string.byte(text, i + 1) local c = string.byte(text, i + 2) -- num = a<<16 + b<<8 + c - local num = a * 65536 + b * 256 + c + local num = a * 65536 + b * 256 + c for j = 1, 4 do --tmp = num >> ((4 -j) * 6) - local tmp = math.floor(num / (2 ^ ((4-j) * 6))) + local tmp = math.floor(num / (2 ^ ((4 - j) * 6))) --curPos = tmp&0x3f local curPos = tmp % 64 + 1 res[index] = ZZBase64.__code[curPos] @@ -2479,52 +2448,52 @@ function ZZBase64.encode(text) if left == 1 then ZZBase64.__left1(res, index, text, len) elseif left == 2 then - ZZBase64.__left2(res, index, text, len) + ZZBase64.__left2(res, index, text, len) end return table.concat(res) end function ZZBase64.__left2(res, index, text, len) local num1 = string.byte(text, len + 1) - num1 = num1 * 1024 --lshift 10 + num1 = num1 * 1024 --lshift 10 local num2 = string.byte(text, len + 2) - num2 = num2 * 4 --lshift 2 + num2 = num2 * 4 --lshift 2 local num = num1 + num2 - + local tmp1 = math.floor(num / 4096) --rShift 12 local curPos = tmp1 % 64 + 1 res[index] = ZZBase64.__code[curPos] - + local tmp2 = math.floor(num / 64) curPos = tmp2 % 64 + 1 res[index + 1] = ZZBase64.__code[curPos] curPos = num % 64 + 1 res[index + 2] = ZZBase64.__code[curPos] - - res[index + 3] = "=" + + res[index + 3] = "=" end -function ZZBase64.__left1(res, index,text, len) +function ZZBase64.__left1(res, index, text, len) local num = string.byte(text, len + 1) - num = num * 16 - + num = num * 16 + local tmp = math.floor(num / 64) local curPos = tmp % 64 + 1 - res[index ] = ZZBase64.__code[curPos] - + res[index] = ZZBase64.__code[curPos] + curPos = num % 64 + 1 res[index + 1] = ZZBase64.__code[curPos] - - res[index + 2] = "=" - res[index + 3] = "=" + + res[index + 2] = "=" + res[index + 3] = "=" end function ZZBase64.decode(text) local len = string.len(text) - local left = 0 + local left = 0 if string.sub(text, len - 1) == "==" then - left = 2 + left = 2 len = len - 4 elseif string.sub(text, len) == "=" then left = 1 @@ -2534,20 +2503,20 @@ function ZZBase64.decode(text) local res = {} local index = 1 local decode = ZZBase64.__decode - for i =1, len, 4 do - local a = decode[string.byte(text,i )] - local b = decode[string.byte(text,i + 1)] - local c = decode[string.byte(text,i + 2)] - local d = decode[string.byte(text,i + 3)] + for i = 1, len, 4 do + local a = decode[string.byte(text, i)] + local b = decode[string.byte(text, i + 1)] + local c = decode[string.byte(text, i + 2)] + local d = decode[string.byte(text, i + 3)] --num = a<<18 + b<<12 + c<<6 + d local num = a * 262144 + b * 4096 + c * 64 + d - + local e = string.char(num % 256) num = math.floor(num / 256) local f = string.char(num % 256) num = math.floor(num / 256) - res[index ] = string.char(num % 256) + res[index] = string.char(num % 256) res[index + 1] = f res[index + 2] = e index = index + 3 @@ -2563,11 +2532,11 @@ end function ZZBase64.__decodeLeft1(res, index, text, len) local decode = ZZBase64.__decode - local a = decode[string.byte(text, len + 1)] - local b = decode[string.byte(text, len + 2)] - local c = decode[string.byte(text, len + 3)] + local a = decode[string.byte(text, len + 1)] + local b = decode[string.byte(text, len + 2)] + local c = decode[string.byte(text, len + 3)] local num = a * 4096 + b * 64 + c - + local num1 = math.floor(num / 1024) % 256 local num2 = math.floor(num / 4) % 256 res[index] = string.char(num1) @@ -2576,14 +2545,11 @@ end function ZZBase64.__decodeLeft2(res, index, text, len) local decode = ZZBase64.__decode - local a = decode[string.byte(text, len + 1)] + local a = decode[string.byte(text, len + 1)] local b = decode[string.byte(text, len + 2)] local num = a * 64 + b num = math.floor(num / 16) res[index] = string.char(num) end - - - return StartDebug diff --git a/lua_probject/extend_project/extend/majiang/100zhang/EXMainView.lua b/lua_probject/extend_project/extend/majiang/100zhang/EXMainView.lua index 55aee9c1..77a50cea 100644 --- a/lua_probject/extend_project/extend/majiang/100zhang/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/100zhang/EXMainView.lua @@ -10,8 +10,8 @@ local M = {} --- Create a new ZZ_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "MainView" self.asset_group = "100Zhang_MJ" self:init() @@ -25,96 +25,89 @@ function M:InitView(url) self._gps_style = 1 self._full = true UIPackage.AddPackage("extend/majiang/100zhang/ui/Extend_MJ_100Zhang") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") self._hu_tip = HuTipView.new(self) - self._view:GetChild('wanfa_text').text =room.room_config.people_num .. '人100张 ' .. room.score_times .. '倍' - - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self:SetReconnentLaiziTips() - - self:PlayerChangeLineState() + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人100张 ' .. room.score_times .. '倍' - if room.playing or room.curren_round > 0 then + self.LaiziBG = self._view:GetChild('n103') + self.LaiziBG.text = "鬼牌" + self.LaiziBG.visible = false + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectlaizi1') + self.Laizi2Btn = self._view:GetChild('selectlaizi2') + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self:SetReconnentLaiziTips() + + self:PlayerChangeLineState() + + if room.playing or room.curren_round > 0 then self:ReloadRoom() end end - - function M:SetReconnentLaiziTips() - local room=DataManager.CurrenRoom - if room.beforelaiziCardId and room.beforelaiziCardId>0 then - self:SetShowLaiZiProcess(room.beforelaiziCardId,room.laiziInfo[1],room.laiziInfo[2],false) - end + local room = DataManager.CurrenRoom + if room.beforelaiziCardId and room.beforelaiziCardId > 0 then + self:SetShowLaiZiProcess(room.beforelaiziCardId, room.laiziInfo[1], room.laiziInfo[2], false) + end end - -function M:SetLaiZiCard(btn,cardId) - btn.icon='ui://Main_Majiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..cardId +function M:SetLaiZiCard(btn, cardId) + btn.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId end - -function M:IsShowLaiZi(btn,isShow) - btn.visible=isShow +function M:IsShowLaiZi(btn, isShow) + btn.visible = isShow end - function M:HideAllLaiZiCard() - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self.LaiziBG.visible=false + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self.LaiziBG.visible = false end -function M:SetShowLaiZiProcess(beforeLaiziID,currentLaizi1ID,currentLaizi2ID,isShowAnim) - --zhongid=currentLaizi1ID - if isShowAnim==nil then isShowAnim=false end - - printlog("当前赋值结果为====>>>") - --print(beforeLaiziID) - --print(currentLaizi1ID) - --print(currentLaizi2ID) - self:HideAllLaiZiCard() - self:SetLaiZiCard(self.selectLaiziBtn,beforeLaiziID) - self:SetLaiZiCard(self.Laizi1Btn,currentLaizi1ID) - if currentLaizi2ID then - self:SetLaiZiCard(self.Laizi2Btn,currentLaizi2ID) - end - - - if isShowAnim==true then - self:IsShowLaiZi(self.selectLaiziBtn,true) - coroutine.start( - function() - coroutine.wait(1) - self:HideAllLaiZiCard() - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - - end - ) - else - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - end - self.LaiziBG.visible=true -end +function M:SetShowLaiZiProcess(beforeLaiziID, currentLaizi1ID, currentLaizi2ID, isShowAnim) + --zhongid=currentLaizi1ID + if isShowAnim == nil then isShowAnim = false end + printlog("当前赋值结果为====>>>") + ---- print(beforeLaiziID) + ---- print(currentLaizi1ID) + ---- print(currentLaizi2ID) + self:HideAllLaiZiCard() + self:SetLaiZiCard(self.selectLaiziBtn, beforeLaiziID) + self:SetLaiZiCard(self.Laizi1Btn, currentLaizi1ID) + if currentLaizi2ID then + self:SetLaiZiCard(self.Laizi2Btn, currentLaizi2ID) + end + + + if isShowAnim == true then + self:IsShowLaiZi(self.selectLaiziBtn, true) + coroutine.start( + function() + coroutine.wait(1) + self:HideAllLaiZiCard() + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + ) + else + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + self.LaiziBG.visible = true +end function M:UpdateRound() self._view:GetChild("tex_round1").text = self._room.curren_round @@ -122,58 +115,58 @@ function M:UpdateRound() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) end - return MJPlayerCardInfoView.new(view,self) + return MJPlayerCardInfoView.new(view, self) end function M:EventInit() - -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MainView.EventInit(self) + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info - local _gamectr = self._gamectr + local _gamectr = self._gamectr - _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) - local arg = {...} - self:SetShowLaiZiProcess(arg[1],arg[2],arg[3],arg[4]) + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4]) end) - _gamectr:AddEventListener(TX_GameEvent.SendCards,function( ... ) + _gamectr:AddEventListener(TX_GameEvent.SendCards, function(...) -- self:ShowHuTip() self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:UpdateHandCard() end end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = {...} + _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) + local arg = { ... } self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) @@ -187,11 +180,11 @@ function M:EventInit() info:UpdateHandCard(true) end) - local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -208,7 +201,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] -- self._tex_leftTime.text = arg[3] @@ -219,27 +212,27 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local weight = arg[2] self:__FangziTip(_tip, weight) end) - - _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + + _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] - local lose_seat = arg[2] - local win_card = arg[3] - local cards = arg[4] - local win_list = arg[5] - local index = self:GetPos(win_seat) - local info = self._player_card_info[index] + local lose_seat = arg[2] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] self:RemoveCursor() info:UpdateHandCard(true, true) @@ -261,74 +254,72 @@ function M:EventInit() if win_seat == lose_seat then url = "ui://Main_Majiang/eff_zimo" end - + local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - he:Center() - if _room.room_config.people_num==2 then - if win_seat ~= _room.self_player.seat then - he.scaleY = 0.4 - he.scaleX = 0.4 - he.x = he.width * 0.4 * 0.5 * -1 - he.y = he.height * 0.4 * 0.5 * -1 - end - end - - if win_seat == _room.self_player.seat then - printlog("自己位置=====") - he:Center() + he:Center() + if _room.room_config.people_num == 2 then + if win_seat ~= _room.self_player.seat then + he.scaleY = 0.4 + he.scaleX = 0.4 + he.x = he.width * 0.4 * 0.5 * -1 + he.y = he.height * 0.4 * 0.5 * -1 + end + end + + if win_seat == _room.self_player.seat then + printlog("自己位置=====") + he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then - printlog("自摸地址==========") + printlog("自摸地址==========") he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end - - - - --- - local isZiMo=win_seat==lose_seat - DataManager.CurrenRoom.isZiMoHu=isZiMo - local hu_sound = isZiMo and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) - printlog("声音====>>>",hu_sound) - self:PlaySound("100Zhang_MJ",player.self_user.sex, hu_sound) - - local pNode = info._view - local url = "eff_list1" + + + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) + printlog("声音====>>>", hu_sound) + self:PlaySound("100Zhang_MJ", player.self_user.sex, hu_sound) + + local pNode = info._view + local url = "eff_list1" local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_100Zhang/" .. url) he_list.touchable = false pNode:AddChild(he_list) he_list:Center() - + coroutine.start(function() - for i = 1 ,#win_list do - local tem = win_list[i] - if tem.type>0 and tem.type<32 then - local com_name = "he" .. tem.type - local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_100Zhang/" .. com_name) - coroutine.wait(0.3) - end - - end - - coroutine.wait(2) - obj_win_card:Dispose() - he:Dispose() - he_list:Dispose() - self._popEvent = true + for i = 1, #win_list do + local tem = win_list[i] + if tem.type > 0 and tem.type < 32 then + local com_name = "he" .. tem.type + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_100Zhang/" .. com_name) + coroutine.wait(0.3) + end + end + + coroutine.wait(2) + obj_win_card:Dispose() + he:Dispose() + he_list:Dispose() + self._popEvent = true end) - end) _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] --ViewUtil.PlaySound("100Zhang_MJ", "extend/majiang/100zhang/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) @@ -337,7 +328,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -355,11 +346,11 @@ function M:EventInit() self:RemoveCursor() if self._clearingView == nil then self._clearingView = EXClearingView.new(self._root_view) - coroutine.start(function() + coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() self._popEvent = true - end) + end) end if _room.curren_round ~= _room.room_config.round then @@ -377,7 +368,7 @@ function M:EventInit() end info:UpdateScore() info._view:GetChild("zhanji").visible = true - local num = data[i].hp_info.total_hp + local num = data[i].hp_info.total_hp if num > 0 then info._view:GetController("text_color").selectedIndex = 0 info._view:GetChild("text_jifen").text = "+" .. d2ad(num) @@ -395,7 +386,7 @@ function M:EventInit() self._clearingView = nil end) end - self._player_card_info[1]:ShowHuTip() + self._player_card_info[1]:ShowHuTip() end) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) @@ -403,7 +394,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -411,7 +402,7 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() - end) + end) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -419,21 +410,21 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() self:UpdateRound() self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 + self._state.selectedIndex = 1 self:__PiaoNiaoTip() end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 - end + end if seat == _room.self_player.seat then - if self._com_piao and _room.self_player.entrust then + if self._com_piao and _room.self_player.entrust then self._com_piao:Dispose() self._com_piao = nil _room.curren_round = _room.curren_round - 1 @@ -444,21 +435,21 @@ end function M:OutCard(card) if card ~= 0 then - printlog("当前出牌为===>>>"..card) + printlog("当前出牌为===>>>" .. card) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card, function() - local info = self._player_card_info[1] - self:RemoveCursor() - info:UpdateHandCard() + local info = self._player_card_info[1] + self:RemoveCursor() + info:UpdateHandCard() - info:UpdateOutCardList(nil, card, self._cursor) - self:PlaySound("100Zhang_MJ", self._room.self_player.self_user.sex,tostring(card)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - else - printlog("鬼牌不能出===>>>"..card) + info:UpdateOutCardList(nil, card, self._cursor) + self:PlaySound("100Zhang_MJ", self._room.self_player.self_user.sex, tostring(card)) + self:PlayMJSound("chupai.mp3") + -- self:ShowHuTip() + end) + else + printlog("鬼牌不能出===>>>" .. card) end end @@ -476,37 +467,37 @@ function M:__FangziTip(tip, weight) local tip_hu = false local count = #_tlist - for k=1,#_tlist do + for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] local url = "ui://Main_Majiang/Btn_fztip" local td_weight = td.weight if td_weight == 16 then td_weight = 8 end if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) + btn_t.onClick:Add(self.__TipAction, self) end -- if not (tonumber(weight) >= 16) then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") + -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") + _btn_pass.onClick:Set(function() + if tonumber(weight) >= 8 then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() _gamectr:SendAction(0) _chipeng_tip:Dispose() self._chipeng_tip = nil - end - end) + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end + end) -- end self._view:AddChild(_chipeng_tip) @@ -549,20 +540,21 @@ function M:_ChiView(tiplist, callback) local item_choose = list_choose:AddItemFromPool() item_choose:GetController("type").selectedIndex = 0 for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", "202_"..tiplist[i].card) + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. tiplist[i].card) end item_choose.onClick:Add(function() callback(tiplist[i].id) end) end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end function M:OnFangziAction(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -572,16 +564,15 @@ function M:OnFangziAction(...) local pNode = info._mask_liangpai local effect = UIPackage.CreateObject("Extend_MJ_100Zhang", "FzEffect") if fz.type == FZType.Peng then - self:PlaySound("100Zhang_MJ", player.self_user.sex,"peng"..math.random(1, 3)) + self:PlaySound("100Zhang_MJ", player.self_user.sex, "peng" .. math.random(1, 3)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") else - - self:PlaySound("100Zhang_MJ", player.self_user.sex,"gang"..math.random(1, 2)) + self:PlaySound("100Zhang_MJ", player.self_user.sex, "gang" .. math.random(1, 2)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") end effect.touchable = false effect:GetTransition("t2"):Play() @@ -605,13 +596,13 @@ end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_100Zhang","Panel_Birds") + self._niao_View = UIPackage.CreateObject("Extend_MJ_100Zhang", "Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do + for i = 1, #list do --添加背面的麻將 local item = list_niao_card:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") @@ -623,7 +614,7 @@ function M:RunNiao(list, start_seat) local card = list[i].card coroutine.wait(0.3) item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_Majiang", "201_"..card) + item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() @@ -648,17 +639,17 @@ end -- end function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end function M:ReloadRoom(bskip) @@ -671,36 +662,36 @@ function M:ReloadRoom(bskip) -- end if bskip == nil or bskip == false then - if not room.playing then - self._state.selectedIndex = 2 - else - self._state.selectedIndex = 1 - self._room._reload_flag = true - end + if not room.playing then + self._state.selectedIndex = 2 + else + self._state.selectedIndex = 1 + self._room._reload_flag = true + end end - + for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end - info:UpdateHandCard() + info:UpdateHandCard() local head_info = self._player_info[self:GetPos(p.seat)] head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true - local num = p.total_hp or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = d2ad(num) - end + local num = p.total_hp or 0 + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = d2ad(num) + end if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() @@ -714,34 +705,34 @@ function M:ReloadRoom(bskip) -- self._player_info[self:GetPos(p.seat)]:Ready(true) -- end if bskip == nil or bskip == false then - if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) - end - end - if p.piao_niao~=nil and p.piao_niao > 0 then + if p.ready and room.playing == false then + self._player_info[self:GetPos(p.seat)]:Ready(true) + end + end + if p.piao_niao ~= nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end -- self:ShowHuTip() - + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() - end + end end function M:PlayerChangeLineState() - -- local isOutCard = true - -- local str = "玩家 " - -- for _ , player in ipairs(self._room.player_list) do - -- if player.line_state == 0 then - -- isOutCard = false - -- end - -- end - -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard + -- local isOutCard = true + -- local str = "玩家 " + -- for _ , player in ipairs(self._room.player_list) do + -- if player.line_state == 0 then + -- isOutCard = false + -- end + -- end + -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard end function M:UpdateCardBox(seat) @@ -775,4 +766,4 @@ function M:Destroy() UIPackage.RemovePackage("extend/majiang/100zhang/ui/Extend_MJ_100Zhang") end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/100zhang/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/100zhang/ExtendConfig.lua index 3cbe6b46..470f91a7 100644 --- a/lua_probject/extend_project/extend/majiang/100zhang/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/100zhang/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,46 +45,46 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - printlog("初始化房间数据====>>>") - pt(_tableInfo) - printlog(_tableInfo.laiziCard) - printlog(_tableInfo.laiziCard2) - printlog(_tableInfo.laiziCardBefore) - printlog(_tableInfo.laiziCard2Before) - - room.laiziInfo={} - if _tableInfo.laiziCardBefore>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard) - if _tableInfo.laiziCard2>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard2) - end - room.beforelaiziCardId=_tableInfo.laiziCardBefore - else - room.laiziInfo=nil - end + printlog("初始化房间数据====>>>") + pt(_tableInfo) + printlog(_tableInfo.laiziCard) + printlog(_tableInfo.laiziCard2) + printlog(_tableInfo.laiziCardBefore) + printlog(_tableInfo.laiziCard2Before) + + room.laiziInfo = {} + if _tableInfo.laiziCardBefore > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard) + if _tableInfo.laiziCard2 > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard2) + end + room.beforelaiziCardId = _tableInfo.laiziCardBefore + else + room.laiziInfo = nil + end local _config = _tableInfo["config"] - pt(_config) + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -93,10 +93,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -107,23 +107,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -147,7 +147,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -156,21 +156,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -186,4 +186,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/100zhang/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/100zhang/MJPlayerSelfCardInfoView.lua index 51ef5dd2..ad01283f 100644 --- a/lua_probject/extend_project/extend/majiang/100zhang/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/100zhang/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -16,16 +16,16 @@ function M.new(view,mainView) end function M:ShowHuTip(card_list) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -34,32 +34,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -72,7 +68,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -91,7 +88,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -108,7 +105,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -116,17 +112,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -159,17 +155,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -189,6 +185,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -203,10 +200,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/changsha/EXClearingView.lua b/lua_probject/extend_project/extend/majiang/changsha/EXClearingView.lua index aa59ffac..50b5ee85 100644 --- a/lua_probject/extend_project/extend/majiang/changsha/EXClearingView.lua +++ b/lua_probject/extend_project/extend/majiang/changsha/EXClearingView.lua @@ -6,8 +6,8 @@ local CS_ClearingView = {} local M = CS_ClearingView function CS_ClearingView.new(blur_view) - setmetatable(M, {__index = ResultView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = ResultView }) + local self = setmetatable({}, { __index = M }) self._full = true ResultView.init(self, "ui://Main_Majiang/clearing") @@ -15,71 +15,64 @@ function CS_ClearingView.new(blur_view) self._blur_view = blur_view self._close_zone = false self._close_destroy = true - - self.xiPaiCtr=self._view:GetController("xipai") - + + self.xiPaiCtr = self._view:GetController("xipai") + self:InitMaPai() return self end - function M:InitMaPai() - self.maPaiCtr=self._view:GetController("mapai") - self.maPaiCtr.selectedIndex=0 - - self.maPaiList={} - - for i=1,10 do - local tempMP=self._view:GetChild("niao"..i) - table.insert(self.maPaiList,tempMP) - end - -end + self.maPaiCtr = self._view:GetController("mapai") + self.maPaiCtr.selectedIndex = 0 + self.maPaiList = {} -function M:IsMapaiShow(niao,isShow) - if niao then - niao.visible=isShow + for i = 1, 10 do + local tempMP = self._view:GetChild("niao" .. i) + table.insert(self.maPaiList, tempMP) end end - -function M:SetMaPaiValue(niao,value) +function M:IsMapaiShow(niao, isShow) if niao then - niao.icon='ui://Main_Majiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..value + niao.visible = isShow end end -function M:SetMaPaiColor(niao,num) - niao:GetController("color").selectedIndex=num +function M:SetMaPaiValue(niao, value) + if niao then + niao.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. value + end +end + +function M:SetMaPaiColor(niao, num) + niao:GetController("color").selectedIndex = num end function M:HideAllMapai() - for i=1,#self.maPaiList do - self:IsMapaiShow(self.maPaiList[i],false) - self:SetMaPaiColor(self.maPaiList[i],0) + for i = 1, #self.maPaiList do + self:IsMapaiShow(self.maPaiList[i], false) + self:SetMaPaiColor(self.maPaiList[i], 0) end end - - function M:ShowSelectMaPai(niaoList) - if niaoList and #niaoList>0 then - self.maPaiCtr.selectedIndex=1 + if niaoList and #niaoList > 0 then + self.maPaiCtr.selectedIndex = 1 self:HideAllMapai() - for i=1,#niaoList do - self:IsMapaiShow(self.maPaiList[i],true) - self:SetMaPaiValue(self.maPaiList[i],niaoList[i].card) - if niaoList[i].score>0 then - self:SetMaPaiColor(self.maPaiList[i],2) + for i = 1, #niaoList do + self:IsMapaiShow(self.maPaiList[i], true) + self:SetMaPaiValue(self.maPaiList[i], niaoList[i].card) + if niaoList[i].score > 0 then + self:SetMaPaiColor(self.maPaiList[i], 2) end end else - self.maPaiCtr.selectedIndex=0 + self.maPaiCtr.selectedIndex = 0 end end - function M:InitData(over, room, result, total_result, callback) self._callback = callback local _overCtr = self._view:GetController("over") @@ -89,47 +82,48 @@ function M:InitData(over, room, result, total_result, callback) local _btnCtr = self._view:GetController("button") local _sdkCtr = self._view:GetController("sdk") local ctr_type = self._view:GetController("type") - self._view:GetChild("tex_roominfo").text = string.format("房号%s 局%s/%s %s", room.room_id, room.curren_round, room.room_config.round, os.date("%Y-%m-%d %H:%M:%S", os.time())) + self._view:GetChild("tex_roominfo").text = string.format("房号%s 局%s/%s %s", room.room_id, room.curren_round, + room.room_config.round, os.date("%Y-%m-%d %H:%M:%S", os.time())) self._view:GetChild("tex_gameinfo").text = string.gsub(room.room_config:GetDes(), "\r", "") -- self._view:GetChild("tex_roomnum").text = room.room_id -- self._view:GetChild("tex_data").text = os.date("%Y-%m-%d %H:%M", os.time()) -- self._view:GetChild("tex_time").text = os.date("%H:%M", os.time()) - local paixingxiangqing=self._view:GetChild("btn_detal") - paixingxiangqing.visible=false - local fanhuipaixing=self._view:GetChild("btn_fanhuipaixing") - fanhuipaixing.visible=false - - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig and round>1 then - self.xiPaiCtr.selectedIndex=1 + local paixingxiangqing = self._view:GetChild("btn_detal") + paixingxiangqing.visible = false + local fanhuipaixing = self._view:GetChild("btn_fanhuipaixing") + fanhuipaixing.visible = false + + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig and round > 1 then + self.xiPaiCtr.selectedIndex = 1 else - self.xiPaiCtr.selectedIndex=0 + self.xiPaiCtr.selectedIndex = 0 end - - + + if result then self:ShowSelectMaPai(result.niao) end - - + + if over ~= 2 then - local xipai=self._view:GetChild("btn_xipai") - xipai.touchable=true + local xipai = self._view:GetChild("btn_xipai") + xipai.touchable = true xipai.onClick:Add(function() - local xiPaiCallBack=function () - xipai.touchable=false - self.xiPaiCtr.selectedIndex=0 - ViewUtil.ErrorTip(1000000,"申请洗牌成功") - end - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendXiPaiAction(xiPaiCallBack) - end) + local xiPaiCallBack = function() + xipai.touchable = false + self.xiPaiCtr.selectedIndex = 0 + ViewUtil.ErrorTip(1000000, "申请洗牌成功") + end + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendXiPaiAction(xiPaiCallBack) + end) if result and result.xipai_score then --xipai.text="洗牌 积分x"..result.xipai_score end - + if result.liuju then ctr_type.selectedIndex = 3 else @@ -155,14 +149,14 @@ function M:InitData(over, room, result, total_result, callback) end) self:AddClearItem(room, result.info_list, nil, over, result.niao, result.active_player) elseif over == 1 then - self.xiPaiCtr.selectedIndex=0 + self.xiPaiCtr.selectedIndex = 0 _btnCtr.selectedIndex = 1 _sdkCtr.selectedIndex = 1 btn_result.onClick:Add(function() _overCtr.selectedIndex = 1 _btnCtr.selectedIndex = 0 _sdkCtr.selectedIndex = 0 - self.maPaiCtr.selectedIndex=0 + self.maPaiCtr.selectedIndex = 0 if self._qsinfo_view then self._qsinfo_view:Dispose() end @@ -173,9 +167,9 @@ function M:InitData(over, room, result, total_result, callback) self:AddClearItem(room, result.info_list, total_result.info_list, over, result.niao, result.active_player) end else - self.xiPaiCtr.selectedIndex=0 + self.xiPaiCtr.selectedIndex = 0 _overCtr.selectedIndex = 1 - self.maPaiCtr.selectedIndex=0 + self.maPaiCtr.selectedIndex = 0 btn_close.onClick:Add(function() ViewManager.ChangeView(ViewManager.View_Lobby) end) @@ -183,7 +177,7 @@ function M:InitData(over, room, result, total_result, callback) end end -function M:AddClearItem(room, data, total_data,over, niao, active_player) +function M:AddClearItem(room, data, total_data, over, niao, active_player) local n = over + 1 local list_view1 = self._view:GetChild("player_list_1") local list_view2 = self._view:GetChild("player_list_2") @@ -202,18 +196,18 @@ function M:AddClearItem(room, data, total_data,over, niao, active_player) end end end - table.sort(data, function(a,b) return a.seat > b.seat end) + table.sort(data, function(a, b) return a.seat > b.seat end) list_view1:RemoveChildrenToPool() - for i=1,#data do + for i = 1, #data do local item = list_view1:AddItemFromPool() self:FillItemData(room, data[i], item, active_player, niao) end - if #data == 3 then + if #data == 3 then list_view1.lineGap = 54 elseif #data == 2 then list_view1.lineGap = 108 end - if 1 == over then + if 1 == over then self:FillItemData2(room, total_data, list_view2) end elseif 2 == over then @@ -225,7 +219,7 @@ function M:FillItemData(room, data, item, active_player) local _gamectr = ControllerManager.GetController(GameController) local p = room:GetPlayerBySeat(data["seat"]) item:GetChild("playerName").text = p.self_user.nick_name - if data.win_count > 3 then + if data.win_count > 3 then item:GetController("mult_win").selectedIndex = 1 -- item:GetChild("tex_win_count").text = string.char(97 + data.win_count - 4) .. "连" end @@ -244,14 +238,14 @@ function M:FillItemData(room, data, item, active_player) end local sp = " " - local str = "胡:"..huadd.."分" - str = str..sp.."扎鸟:"..birdadd.."分" - str = str..sp.."起手胡:"..qsadd.."分" + local str = "胡:" .. huadd .. "分" + str = str .. sp .. "扎鸟:" .. birdadd .. "分" + str = str .. sp .. "起手胡:" .. qsadd .. "分" -- if #qs_niao_list > 0 then -- str = str .. "(摇骰点数:" .. qs_niao_list[1].card .. " " .. qs_niao_list[2].card .. ")" -- end if data["piao_niao_score"] then - str = str..sp.."飘鸟:"..data["piao_niao_score"].."分" + str = str .. sp .. "飘鸟:" .. data["piao_niao_score"] .. "分" end item:GetChild("score1").text = str local win_list = data["win_list"] @@ -259,7 +253,7 @@ function M:FillItemData(room, data, item, active_player) if win_list then local str1 = "" item:GetController("hu_list").selectedIndex = 1 - for i = 1, #win_list do + for i = 1, #win_list do local str2 = "" if win_list[i].type == 1 then local value = win_list[i].value @@ -271,7 +265,7 @@ function M:FillItemData(room, data, item, active_player) end str2 = CS_Win_Type[win_list[i].type] end - str1 = str1..str2..sp + str1 = str1 .. str2 .. sp end item:GetChild("score3").text = str1 end @@ -284,9 +278,9 @@ function M:FillItemData(room, data, item, active_player) if data["is_win"] and active_player == p.self_user.account_id and remove_win_card then list_remove(hand_cards, data["win_card"]) end - for i=1,#hand_cards do + for i = 1, #hand_cards do local card = hand_list_view:AddItemFromPool() - card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_"..hand_cards[i] + card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. hand_cards[i] end hand_list_view.width = 52 * #hand_cards @@ -294,27 +288,27 @@ function M:FillItemData(room, data, item, active_player) local fz_card_list = item:GetChild("fz_card_list") fz_card_list.width = 157 * #fz_card * 0.8 fz_card_list:RemoveChildrenToPool() - for i=1,#fz_card do + for i = 1, #fz_card do if fz_card[i].type == FZType.Peng then local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3") - for j=1,3 do + for j = 1, 3 do local card = item:GetChild("card_" .. j) - card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_"..fz_card[i].card + card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].card end elseif fz_card[i].type == FZType.Chi then local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3") - for j = 1,3 do + for j = 1, 3 do local card = item:GetChild("card_" .. j) - card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_"..fz_card[i].opcard[j] + card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].opcard[j] end elseif fz_card[i].type == FZType.Gang or fz_card[i].type == FZType.Gang_An or fz_card[i].type == FZType.Gang_Peng then local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_4") - for j=1,4 do + for j = 1, 4 do local card = item:GetChild("card_" .. j) if fz_card[i].type == FZType.Gang_An and j == 4 then card.icon = "ui://Main_Majiang/202_00" else - card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_"..fz_card[i].card + card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].card end end end @@ -322,7 +316,7 @@ function M:FillItemData(room, data, item, active_player) -- local total_score = data["total_score"] if total >= 0 then - item:GetChild("score2").text = "+"..total + item:GetChild("score2").text = "+" .. total item:GetChild("score2").grayed = false else item:GetChild("score2").text = total @@ -342,13 +336,13 @@ function M:FillItemData(room, data, item, active_player) local is_win = data["is_win"] or false item:GetController("win").selectedIndex = is_win and 0 or 1 - --print(p.self_user.account_id, active_player) - if p.self_user.account_id == active_player and is_win == false and not data["liuju"] then - item:GetController("win").selectedIndex = 2 + ---- print(p.self_user.account_id, active_player) + if p.self_user.account_id == active_player and is_win == false and not data["liuju"] then + item:GetController("win").selectedIndex = 2 end local win_card = item:GetChild("win_card") - if is_win then - win_card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_"..data["win_card"] + if is_win then + win_card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. data["win_card"] end if data.niao then item:GetController("niao").selectedIndex = 1 @@ -357,7 +351,7 @@ function M:FillItemData(room, data, item, active_player) local niao = data.niao for i = 1, #niao do local card_niao = lst_niao:AddItemFromPool() - card_niao.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. niao[i] + card_niao.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. niao[i] end end if p.seat == room.banker_seat then @@ -370,75 +364,76 @@ function M:FillItemData(room, data, item, active_player) end function M:FillItemData2(room, data, list) - -- 赋值result_info,聊天室分享需要 - local player_list = {} - for i = 1, #data do - player_list[i] = {} - local user = room:GetPlayerBySeat(data[i].seat).self_user - player_list[i].id = user.account_id - player_list[i].hp_info = data[i].hp_info - player_list[i].score = data[i].total_score - player_list[i].house = room.owner_id == player_list[i].id and 1 or 0 - player_list[i].nick = user.nick_name - player_list[i].head_url = user.head_url + -- 赋值result_info,聊天室分享需要 + local player_list = {} + for i = 1, #data do + player_list[i] = {} + local user = room:GetPlayerBySeat(data[i].seat).self_user + player_list[i].id = user.account_id + player_list[i].hp_info = data[i].hp_info + player_list[i].score = data[i].total_score + player_list[i].house = room.owner_id == player_list[i].id and 1 or 0 + player_list[i].nick = user.nick_name + player_list[i].head_url = user.head_url local settle_log = data[i].settle_log - player_list[i].param = {} - player_list[i].param[1]={} - player_list[i].param[1].key = "大胡自摸:" - player_list[i].param[1].value = tostring(data[i].settle_log.da_zimo) - player_list[i].param[2]={} - player_list[i].param[2].key = "小胡自摸:" - player_list[i].param[2].value = tostring(data[i].settle_log.xiao_zimo) - player_list[i].param[3]={} - player_list[i].param[3].key = "大胡接炮:" - player_list[i].param[3].value = tostring(data[i].settle_log.da_jie_pao) - player_list[i].param[4]={} - player_list[i].param[4].key = "小胡接炮:" - player_list[i].param[4].value = tostring(data[i].settle_log.xiao_jie_pao) - player_list[i].param[5]={} - player_list[i].param[5].key = "大胡点炮:" - player_list[i].param[5].value = tostring(data[i].settle_log.da_dian_pao) - player_list[i].param[6]={} - player_list[i].param[6].key = "小胡点炮:" - player_list[i].param[6].value = tostring(data[i].settle_log.xiao_dian_pao) - end - local round = room.room_config.round - self:GenerateRoomResultInfo(round, room.room_config:GetGameName(), room.room_id, room.create_time, player_list) - -- self:SetGSListlineGap(-10) + player_list[i].param = {} + player_list[i].param[1] = {} + player_list[i].param[1].key = "大胡自摸:" + player_list[i].param[1].value = tostring(data[i].settle_log.da_zimo) + player_list[i].param[2] = {} + player_list[i].param[2].key = "小胡自摸:" + player_list[i].param[2].value = tostring(data[i].settle_log.xiao_zimo) + player_list[i].param[3] = {} + player_list[i].param[3].key = "大胡接炮:" + player_list[i].param[3].value = tostring(data[i].settle_log.da_jie_pao) + player_list[i].param[4] = {} + player_list[i].param[4].key = "小胡接炮:" + player_list[i].param[4].value = tostring(data[i].settle_log.xiao_jie_pao) + player_list[i].param[5] = {} + player_list[i].param[5].key = "大胡点炮:" + player_list[i].param[5].value = tostring(data[i].settle_log.da_dian_pao) + player_list[i].param[6] = {} + player_list[i].param[6].key = "小胡点炮:" + player_list[i].param[6].value = tostring(data[i].settle_log.xiao_dian_pao) + end + local round = room.room_config.round + self:GenerateRoomResultInfo(round, room.room_config:GetGameName(), room.room_id, room.create_time, player_list) + -- self:SetGSListlineGap(-10) local big_result = self._view:GetChild("big_result") - big_result:GetChild("txt_room_info").text = string.format("%s 房号%s 局%s/%s", os.date("%Y/%m/%d", os.time()), room.room_id, room.curren_round, room.room_config.round) - local lst_p = big_result:GetChild("player_list") - if #player_list == 3 then + big_result:GetChild("txt_room_info").text = string.format("%s 房号%s 局%s/%s", os.date("%Y/%m/%d", os.time()), + room.room_id, room.curren_round, room.room_config.round) + local lst_p = big_result:GetChild("player_list") + if #player_list == 3 then lst_p.columnGap = 108 elseif #player_list == 2 then lst_p.columnGap = 208 end - self:InitBigResult(room, 30) + self:InitBigResult(room, 30) local show_detail = room.hpOnOff == 1 - for i = 1, lst_p.numChildren do - local com_p = lst_p:GetChildAt(i - 1) - local list_param = com_p:GetChild("list_param") - for j = 1, list_param.numChildren do - local tem = list_param:GetChildAt(j - 1) - tem:GetChild("txt_value").textFormat.size = 30 - end - if show_detail then - local score = 0 - if com_p:GetController("pn").selectedIndex == 0 then - score = com_p:GetChild("txt_navigate").text - else - score = com_p:GetChild("txt_positive").text - end - score = score / room.score_times - com_p:GetChild("tex_detail_score").text = string.format("%s × %s倍", score, room.score_times) - end - end - if room.group_id ~= 0 then - big_result:GetController("group").selectedIndex = 1 - end - DataManager.CurrenRoom = nil + for i = 1, lst_p.numChildren do + local com_p = lst_p:GetChildAt(i - 1) + local list_param = com_p:GetChild("list_param") + for j = 1, list_param.numChildren do + local tem = list_param:GetChildAt(j - 1) + tem:GetChild("txt_value").textFormat.size = 30 + end + if show_detail then + local score = 0 + if com_p:GetController("pn").selectedIndex == 0 then + score = com_p:GetChild("txt_navigate").text + else + score = com_p:GetChild("txt_positive").text + end + score = score / room.score_times + com_p:GetChild("tex_detail_score").text = string.format("%s × %s倍", score, room.score_times) + end + end + if room.group_id ~= 0 then + big_result:GetController("group").selectedIndex = 1 + end + DataManager.CurrenRoom = nil end -- 起手胡详情 @@ -472,7 +467,7 @@ function M:__AddQSInfo(data, nick, room) cards[card] = 1 end end - for k,v in pairs(cards) do + for k, v in pairs(cards) do local card = k if card_map[card] then if card_map[card] < cards[card] then @@ -484,7 +479,7 @@ function M:__AddQSInfo(data, nick, room) end end local all_cards = {} - for j,v in pairs(card_map) do + for j, v in pairs(card_map) do for k = 1, v do table.insert(all_cards, j) end @@ -493,11 +488,11 @@ function M:__AddQSInfo(data, nick, room) for j = 1, #all_cards do local citem = lst_card:AddItemFromPool() citem.touchable = false - citem.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_"..all_cards[j] + citem.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. all_cards[j] end local cs_zhua_niao = room.room_config.niao_type == 2 qsinfo:GetController("niao").selectedIndex = cs_zhua_niao and 1 or 0 - item:GetChild("tex_touzi").text = cs_zhua_niao and (tem.niao[1].card .. " " .. tem.niao[2].card) or "" + item:GetChild("tex_touzi").text = cs_zhua_niao and (tem.niao[1].card .. " " .. tem.niao[2].card) or "" item:GetChild("tex_score").text = tem.score item:GetChild("tex_niao_score").text = cs_zhua_niao and tem.niao_score or "" end @@ -512,12 +507,12 @@ function M:__AddQSInfo(data, nick, room) local _touch_start_pos = nil self._view:AddChild(qsinfo) local btn_di = qsinfo:GetChild("btn_di") - btn_di.onTouchBegin:Add(function(context) + btn_di.onTouchBegin:Add(function(context) _view_start_pos = Vector2(qsinfo.x, qsinfo.y) _touch_start_pos = self._view:GlobalToLocal(Vector2(context.inputEvent.x, context.inputEvent.y)) end) btn_di.onTouchMove:Add(function(context) - local xy = self._view:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) + local xy = self._view:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) local dist = Vector2(xy.x - _touch_start_pos.x, xy.y - _touch_start_pos.y) local posx = _view_start_pos.x + dist.x local posy = _view_start_pos.y + dist.y @@ -542,16 +537,16 @@ end local prefix function M:GetPrefix() -- if not prefix then - prefix = get_majiang_prefix(10) - -- end + prefix = get_majiang_prefix(10) + -- end return prefix end -function M:DestroyWithCallback() +function M:DestroyWithCallback() if self._callback then self._callback() end self:Destroy() end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua b/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua index 69a292d5..12b8a728 100644 --- a/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua @@ -29,8 +29,8 @@ local M = {} --- Create a new CS_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "CS_MainView" self.asset_group = "ChangSha_MJ" self:init() @@ -47,7 +47,7 @@ function M:InitView(url) -- self.Fix_Msg_Chat = Fix_Msg_Chat UIPackage.AddPackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") @@ -68,7 +68,7 @@ function M:InitView(url) self._hu_tip = HuTipView.new(self) self:PlayerChangeLineState() - --print("CS_MainView") + ---- print("CS_MainView") if (room.playing or room.curren_round > 0) or room.status == 1 then self:ReloadRoom() end @@ -111,8 +111,8 @@ function M:EventInit() end end) - _gamectr:AddEventListener(CS_GameEvent.SendCards,function( ... ) - local arg = {...} + _gamectr:AddEventListener(CS_GameEvent.SendCards, function(...) + local arg = { ... } self._tex_LeftCard.text = arg[1] local info = self._player_card_info[1] info._player.auto_out_card = false @@ -451,10 +451,10 @@ function M:EventInit() end) _gamectr:AddEventListener(CS_GameEvent.EvnetPiaoTip, function() - self:UpdateRound() - self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 - if oldGameVersion==1 then + self:UpdateRound() + self._tex_LeftCard.text = "0" + self._state.selectedIndex = 1 + if oldGameVersion == 1 then self:__PiaoNiaoTip() else self:__PiaoNiaoTip1() @@ -516,8 +516,8 @@ function M:EventInit() end function M:UpdateRound() - self._view:GetChild("tex_round1").text = self._room.curren_round - self._view:GetChild("tex_round2").text = self._room.room_config.round + self._view:GetChild("tex_round1").text = self._room.curren_round + self._view:GetChild("tex_round2").text = self._room.room_config.round end function M:InitPlayerInfoView() @@ -535,7 +535,7 @@ function M:OutCard(card) -- 防止同一帧内执行两次OutCard事件 local last_discard_frame = discard_frame discard_frame = Time.frameCount - --print("帧数:-------------------------",discard_frame, last_discard_frame, discard_frame == last_discard_frame) + ---- print("帧数:-------------------------",discard_frame, last_discard_frame, discard_frame == last_discard_frame) if discard_frame == last_discard_frame then return end diff --git a/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua b/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua index d2746b98..afc645aa 100644 --- a/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua @@ -32,17 +32,17 @@ local function CardPos(obj, area, oder, loc, offset) end function M:UpdateHandCard(getcard, mp, opcard) - -- mp 是否明牌 - -- 如果不明牌,但是有 opcard 表示是起手胡 - getcard = getcard or false - mp = mp or false - local handcard_list = self._mask_data["handcard_list"] - local oder = handcard_list["oder"] - local _player = self._player - local comp_back = handcard_list["comp_back"] - local comp = handcard_list["comp"] - local outcard_list = self._mask_data["outcard_list"] - local card = outcard_list["card"] + -- mp 是否明牌 + -- 如果不明牌,但是有 opcard 表示是起手胡 + getcard = getcard or false + mp = mp or false + local handcard_list = self._mask_data["handcard_list"] + local oder = handcard_list["oder"] + local _player = self._player + local comp_back = handcard_list["comp_back"] + local comp = handcard_list["comp"] + local outcard_list = self._mask_data["outcard_list"] + local card = outcard_list["card"] self._area_handcard_list:RemoveChildren(0, -1, true) local opnum = opcard and #opcard or -1 @@ -73,7 +73,7 @@ function M:UpdateHandCard(getcard, mp, opcard) if opnum ~= -1 then loc = CardPos(obj, self._area_handcard_list, oder, loc, offset) else - ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) + ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) end --改变左右两边的手牌的x值 if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then @@ -89,8 +89,8 @@ function M:UpdateHandCard(getcard, mp, opcard) local outcard_list = self._mask_data["outcard_list"] local comp = handcard_list["comp"] local card = outcard_list["card"] - --print("comp"..comp) - -- print(vardump(_player.card_list)) + ---- print("comp"..comp) + -- -- print(vardump(_player.card_list)) if self._current_card_type == 2 then comp = comp .. "_3d" diff --git a/lua_probject/extend_project/extend/majiang/changsha/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/changsha/MJPlayerSelfCardInfoView.lua index 003db705..d7ebb0c5 100644 --- a/lua_probject/extend_project/extend/majiang/changsha/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/changsha/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -36,7 +36,8 @@ function M:UpdateHandCard(getcard, mp, opcard) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.tingPai(card_list, DataManager.CurrenRoom.self_player.fz_list, DataManager.CurrenRoom.room_config.no_jiang) + local tingList = CardCheck.tingPai(card_list, DataManager.CurrenRoom.self_player.fz_list, + DataManager.CurrenRoom.room_config.no_jiang) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -55,7 +56,7 @@ function M:UpdateHandCard(getcard, mp, opcard) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -96,7 +97,7 @@ function M:UpdateHandCard(getcard, mp, opcard) end end end - else + else for i = 1, #_carViewList do local btn = _carViewList[i].card local tem = string.gsub(btn.icon, "ui://Main_Majiang/", "") @@ -112,7 +113,7 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) if btn ~= button and btn.selected == true then @@ -139,7 +140,7 @@ function M:__OnClickHandCard(context) self._mainView:markOutCards(false, button.data.card_item) end end - + local _room = DataManager.CurrenRoom -- if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then -- local card = button.data @@ -152,18 +153,18 @@ function M:__OnClickHandCard(context) end function M:__OnDragEnd(context, offset) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - -- + -- --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) - -- print(button.y - card.old_postion.y) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print(button.y - card.old_postion.y) -- if (button.y < -55 and _room.curren_outcard_seat == _room.self_player.seat) and self:CheckPlayerOnlineState() then if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat) then self._mainView:OutCard(card.card_item) @@ -184,6 +185,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -198,10 +200,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/chaoshan/EXMainView.lua b/lua_probject/extend_project/extend/majiang/chaoshan/EXMainView.lua index 86319fd6..5b5905d1 100644 --- a/lua_probject/extend_project/extend/majiang/chaoshan/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/chaoshan/EXMainView.lua @@ -10,8 +10,8 @@ local M = {} --- Create a new ZZ_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "MainView" self.asset_group = "ChaoShan_MJ" self:init() @@ -25,96 +25,89 @@ function M:InitView(url) self._gps_style = 1 self._full = true UIPackage.AddPackage("extend/majiang/chaoshan/ui/Extend_MJ_ChaoShan") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") self._hu_tip = HuTipView.new(self) - self._view:GetChild('wanfa_text').text =room.room_config.people_num .. '人潮汕 ' .. room.score_times .. '倍' - - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self:SetReconnentLaiziTips() - - self:PlayerChangeLineState() + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人潮汕 ' .. room.score_times .. '倍' - if room.playing or room.curren_round > 0 then + self.LaiziBG = self._view:GetChild('n103') + self.LaiziBG.text = "鬼牌" + self.LaiziBG.visible = false + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectlaizi1') + self.Laizi2Btn = self._view:GetChild('selectlaizi2') + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self:SetReconnentLaiziTips() + + self:PlayerChangeLineState() + + if room.playing or room.curren_round > 0 then self:ReloadRoom() end end - - function M:SetReconnentLaiziTips() - local room=DataManager.CurrenRoom - if room.beforelaiziCardId and room.beforelaiziCardId>0 then - self:SetShowLaiZiProcess(room.beforelaiziCardId,room.laiziInfo[1],room.laiziInfo[2],false) - end + local room = DataManager.CurrenRoom + if room.beforelaiziCardId and room.beforelaiziCardId > 0 then + self:SetShowLaiZiProcess(room.beforelaiziCardId, room.laiziInfo[1], room.laiziInfo[2], false) + end end - -function M:SetLaiZiCard(btn,cardId) - btn.icon='ui://Main_Majiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..cardId +function M:SetLaiZiCard(btn, cardId) + btn.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId end - -function M:IsShowLaiZi(btn,isShow) - btn.visible=isShow +function M:IsShowLaiZi(btn, isShow) + btn.visible = isShow end - function M:HideAllLaiZiCard() - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self.LaiziBG.visible=false + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self.LaiziBG.visible = false end -function M:SetShowLaiZiProcess(beforeLaiziID,currentLaizi1ID,currentLaizi2ID,isShowAnim) - --zhongid=currentLaizi1ID - if isShowAnim==nil then isShowAnim=false end - - printlog("当前赋值结果为====>>>") - print(beforeLaiziID) - print(currentLaizi1ID) - print(currentLaizi2ID) - self:HideAllLaiZiCard() - self:SetLaiZiCard(self.selectLaiziBtn,beforeLaiziID) - self:SetLaiZiCard(self.Laizi1Btn,currentLaizi1ID) - if currentLaizi2ID then - self:SetLaiZiCard(self.Laizi2Btn,currentLaizi2ID) - end - - - if isShowAnim==true then - self:IsShowLaiZi(self.selectLaiziBtn,true) - coroutine.start( - function() - coroutine.wait(1) - self:HideAllLaiZiCard() - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - - end - ) - else - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - end - self.LaiziBG.visible=true -end +function M:SetShowLaiZiProcess(beforeLaiziID, currentLaizi1ID, currentLaizi2ID, isShowAnim) + --zhongid=currentLaizi1ID + if isShowAnim == nil then isShowAnim = false end + printlog("当前赋值结果为====>>>") + -- print(beforeLaiziID) + -- print(currentLaizi1ID) + -- print(currentLaizi2ID) + self:HideAllLaiZiCard() + self:SetLaiZiCard(self.selectLaiziBtn, beforeLaiziID) + self:SetLaiZiCard(self.Laizi1Btn, currentLaizi1ID) + if currentLaizi2ID then + self:SetLaiZiCard(self.Laizi2Btn, currentLaizi2ID) + end + + + if isShowAnim == true then + self:IsShowLaiZi(self.selectLaiziBtn, true) + coroutine.start( + function() + coroutine.wait(1) + self:HideAllLaiZiCard() + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + ) + else + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + self.LaiziBG.visible = true +end function M:UpdateRound() self._view:GetChild("tex_round1").text = self._room.curren_round @@ -122,58 +115,58 @@ function M:UpdateRound() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) end - return MJPlayerCardInfoView.new(view,self) + return MJPlayerCardInfoView.new(view, self) end function M:EventInit() - -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MainView.EventInit(self) + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info - local _gamectr = self._gamectr + local _gamectr = self._gamectr - _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) - local arg = {...} - self:SetShowLaiZiProcess(arg[1],arg[2],arg[3],arg[4]) + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4]) end) - _gamectr:AddEventListener(TX_GameEvent.SendCards,function( ... ) + _gamectr:AddEventListener(TX_GameEvent.SendCards, function(...) -- self:ShowHuTip() self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:UpdateHandCard() end end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = {...} + _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) + local arg = { ... } self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) @@ -187,11 +180,11 @@ function M:EventInit() info:UpdateHandCard(true) end) - local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -208,7 +201,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] -- self._tex_leftTime.text = arg[3] @@ -219,27 +212,27 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local weight = arg[2] self:__FangziTip(_tip, weight) end) - - _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + + _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] - local lose_seat = arg[2] - local win_card = arg[3] - local cards = arg[4] - local win_list = arg[5] - local index = self:GetPos(win_seat) - local info = self._player_card_info[index] + local lose_seat = arg[2] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] self:RemoveCursor() info:UpdateHandCard(true, true) @@ -261,74 +254,72 @@ function M:EventInit() if win_seat == lose_seat then url = "ui://Main_Majiang/eff_zimo" end - + local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - he:Center() - if _room.room_config.people_num==2 then - if win_seat ~= _room.self_player.seat then - he.scaleY = 0.4 - he.scaleX = 0.4 - he.x = he.width * 0.4 * 0.5 * -1 - he.y = he.height * 0.4 * 0.5 * -1 - end - end - - if win_seat == _room.self_player.seat then - printlog("自己位置=====") - he:Center() + he:Center() + if _room.room_config.people_num == 2 then + if win_seat ~= _room.self_player.seat then + he.scaleY = 0.4 + he.scaleX = 0.4 + he.x = he.width * 0.4 * 0.5 * -1 + he.y = he.height * 0.4 * 0.5 * -1 + end + end + + if win_seat == _room.self_player.seat then + printlog("自己位置=====") + he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then - printlog("自摸地址==========") + printlog("自摸地址==========") he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end - - - - --- - local isZiMo=win_seat==lose_seat - DataManager.CurrenRoom.isZiMoHu=isZiMo - local hu_sound = isZiMo and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) - printlog("声音====>>>",hu_sound) - self:PlaySound("ChaoShan_MJ",player.self_user.sex, hu_sound) - - local pNode = info._view - local url = "eff_list1" + + + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) + printlog("声音====>>>", hu_sound) + self:PlaySound("ChaoShan_MJ", player.self_user.sex, hu_sound) + + local pNode = info._view + local url = "eff_list1" local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChaoShan/" .. url) he_list.touchable = false pNode:AddChild(he_list) he_list:Center() - + coroutine.start(function() - for i = 1 ,#win_list do - local tem = win_list[i] - if tem.type>0 and tem.type<32 then - local com_name = "he" .. tem.type - local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChaoShan/" .. com_name) - coroutine.wait(0.3) - end - - end - - coroutine.wait(2) - obj_win_card:Dispose() - he:Dispose() - he_list:Dispose() - self._popEvent = true + for i = 1, #win_list do + local tem = win_list[i] + if tem.type > 0 and tem.type < 32 then + local com_name = "he" .. tem.type + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChaoShan/" .. com_name) + coroutine.wait(0.3) + end + end + + coroutine.wait(2) + obj_win_card:Dispose() + he:Dispose() + he_list:Dispose() + self._popEvent = true end) - end) _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] - -- ViewUtil.PlaySound("ChaoShan_MJ", "extend/majiang/chaoshan/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + -- ViewUtil.PlaySound("ChaoShan_MJ", "extend/majiang/chaoshan/sound/zhuaniao.mp3") + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) @@ -337,7 +328,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -355,11 +346,11 @@ function M:EventInit() self:RemoveCursor() if self._clearingView == nil then self._clearingView = EXClearingView.new(self._root_view) - coroutine.start(function() + coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() self._popEvent = true - end) + end) end if _room.curren_round ~= _room.room_config.round then @@ -377,7 +368,7 @@ function M:EventInit() end info:UpdateScore() info._view:GetChild("zhanji").visible = true - local num = data[i].hp_info.total_hp + local num = data[i].hp_info.total_hp if num > 0 then info._view:GetController("text_color").selectedIndex = 0 info._view:GetChild("text_jifen").text = "+" .. d2ad(num) @@ -395,7 +386,7 @@ function M:EventInit() self._clearingView = nil end) end - self._player_card_info[1]:ShowHuTip() + self._player_card_info[1]:ShowHuTip() end) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) @@ -403,7 +394,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -411,7 +402,7 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() - end) + end) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -419,21 +410,21 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() self:UpdateRound() self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 + self._state.selectedIndex = 1 self:__PiaoNiaoTip() end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 - end + end if seat == _room.self_player.seat then - if self._com_piao and _room.self_player.entrust then + if self._com_piao and _room.self_player.entrust then self._com_piao:Dispose() self._com_piao = nil _room.curren_round = _room.curren_round - 1 @@ -444,21 +435,21 @@ end function M:OutCard(card) if card ~= 0 then - printlog("当前出牌为===>>>"..card) + printlog("当前出牌为===>>>" .. card) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card, function() - local info = self._player_card_info[1] - self:RemoveCursor() - info:UpdateHandCard() + local info = self._player_card_info[1] + self:RemoveCursor() + info:UpdateHandCard() - info:UpdateOutCardList(nil, card, self._cursor) - self:PlaySound("ChaoShan_MJ", self._room.self_player.self_user.sex,tostring(card)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - else - printlog("鬼牌不能出===>>>"..card) + info:UpdateOutCardList(nil, card, self._cursor) + self:PlaySound("ChaoShan_MJ", self._room.self_player.self_user.sex, tostring(card)) + self:PlayMJSound("chupai.mp3") + -- self:ShowHuTip() + end) + else + printlog("鬼牌不能出===>>>" .. card) end end @@ -476,37 +467,37 @@ function M:__FangziTip(tip, weight) local tip_hu = false local count = #_tlist - for k=1,#_tlist do + for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] local url = "ui://Main_Majiang/Btn_fztip" local td_weight = td.weight if td_weight == 16 then td_weight = 8 end if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) + btn_t.onClick:Add(self.__TipAction, self) end -- if not (tonumber(weight) >= 16) then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") + -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") + _btn_pass.onClick:Set(function() + if tonumber(weight) >= 8 then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() _gamectr:SendAction(0) _chipeng_tip:Dispose() self._chipeng_tip = nil - end - end) + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end + end) -- end self._view:AddChild(_chipeng_tip) @@ -549,20 +540,21 @@ function M:_ChiView(tiplist, callback) local item_choose = list_choose:AddItemFromPool() item_choose:GetController("type").selectedIndex = 0 for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", "202_"..tiplist[i].card) + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. tiplist[i].card) end item_choose.onClick:Add(function() callback(tiplist[i].id) end) end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end function M:OnFangziAction(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -572,16 +564,15 @@ function M:OnFangziAction(...) local pNode = info._mask_liangpai local effect = UIPackage.CreateObject("Extend_MJ_ChaoShan", "FzEffect") if fz.type == FZType.Peng then - self:PlaySound("ChaoShan_MJ", player.self_user.sex,"peng"..math.random(1, 3)) + self:PlaySound("ChaoShan_MJ", player.self_user.sex, "peng" .. math.random(1, 3)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") else - - self:PlaySound("ChaoShan_MJ", player.self_user.sex,"gang"..math.random(1, 2)) + self:PlaySound("ChaoShan_MJ", player.self_user.sex, "gang" .. math.random(1, 2)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") end effect.touchable = false effect:GetTransition("t2"):Play() @@ -605,13 +596,13 @@ end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_ChaoShan","Panel_Birds") + self._niao_View = UIPackage.CreateObject("Extend_MJ_ChaoShan", "Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do + for i = 1, #list do --添加背面的麻將 local item = list_niao_card:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") @@ -623,7 +614,7 @@ function M:RunNiao(list, start_seat) local card = list[i].card coroutine.wait(0.3) item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_Majiang", "201_"..card) + item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() @@ -648,17 +639,17 @@ end -- end function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end function M:ReloadRoom(bskip) @@ -671,36 +662,36 @@ function M:ReloadRoom(bskip) -- end if bskip == nil or bskip == false then - if not room.playing then - self._state.selectedIndex = 2 - else - self._state.selectedIndex = 1 - self._room._reload_flag = true - end + if not room.playing then + self._state.selectedIndex = 2 + else + self._state.selectedIndex = 1 + self._room._reload_flag = true + end end - + for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end - info:UpdateHandCard() + info:UpdateHandCard() local head_info = self._player_info[self:GetPos(p.seat)] head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true - local num = p.total_hp or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = d2ad(num) - end + local num = p.total_hp or 0 + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = d2ad(num) + end if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() @@ -714,34 +705,34 @@ function M:ReloadRoom(bskip) -- self._player_info[self:GetPos(p.seat)]:Ready(true) -- end if bskip == nil or bskip == false then - if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) - end - end - if p.piao_niao~=nil and p.piao_niao > 0 then + if p.ready and room.playing == false then + self._player_info[self:GetPos(p.seat)]:Ready(true) + end + end + if p.piao_niao ~= nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end -- self:ShowHuTip() - + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() - end + end end function M:PlayerChangeLineState() - -- local isOutCard = true - -- local str = "玩家 " - -- for _ , player in ipairs(self._room.player_list) do - -- if player.line_state == 0 then - -- isOutCard = false - -- end - -- end - -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard + -- local isOutCard = true + -- local str = "玩家 " + -- for _ , player in ipairs(self._room.player_list) do + -- if player.line_state == 0 then + -- isOutCard = false + -- end + -- end + -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard end function M:UpdateCardBox(seat) @@ -775,4 +766,4 @@ function M:Destroy() UIPackage.RemovePackage("extend/majiang/chaoshan/ui/Extend_MJ_ChaoShan") end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/chaoshan/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/chaoshan/ExtendConfig.lua index e9fb85f8..26b10e0d 100644 --- a/lua_probject/extend_project/extend/majiang/chaoshan/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/chaoshan/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,46 +45,46 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - printlog("初始化房间数据====>>>") - pt(_tableInfo) - printlog(_tableInfo.laiziCard) - printlog(_tableInfo.laiziCard2) - printlog(_tableInfo.laiziCardBefore) - printlog(_tableInfo.laiziCard2Before) - - room.laiziInfo={} - if _tableInfo.laiziCardBefore>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard) - if _tableInfo.laiziCard2>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard2) - end - room.beforelaiziCardId=_tableInfo.laiziCardBefore - else - room.laiziInfo=nil - end + printlog("初始化房间数据====>>>") + pt(_tableInfo) + printlog(_tableInfo.laiziCard) + printlog(_tableInfo.laiziCard2) + printlog(_tableInfo.laiziCardBefore) + printlog(_tableInfo.laiziCard2Before) + + room.laiziInfo = {} + if _tableInfo.laiziCardBefore > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard) + if _tableInfo.laiziCard2 > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard2) + end + room.beforelaiziCardId = _tableInfo.laiziCardBefore + else + room.laiziInfo = nil + end local _config = _tableInfo["config"] - pt(_config) + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -93,10 +93,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -107,23 +107,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -147,7 +147,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -156,21 +156,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -186,4 +186,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/chaoshan/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/chaoshan/MJPlayerSelfCardInfoView.lua index 51ef5dd2..ad01283f 100644 --- a/lua_probject/extend_project/extend/majiang/chaoshan/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/chaoshan/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -16,16 +16,16 @@ function M.new(view,mainView) end function M:ShowHuTip(card_list) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -34,32 +34,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -72,7 +68,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -91,7 +88,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -108,7 +105,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -116,17 +112,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -159,17 +155,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -189,6 +185,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -203,10 +200,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/chaozhou/EXMainView.lua b/lua_probject/extend_project/extend/majiang/chaozhou/EXMainView.lua index 374d077f..c5a11d19 100644 --- a/lua_probject/extend_project/extend/majiang/chaozhou/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/chaozhou/EXMainView.lua @@ -10,8 +10,8 @@ local M = {} --- Create a new ZZ_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "MainView" self.asset_group = "ChaoZhou_MJ" self:init() @@ -25,96 +25,89 @@ function M:InitView(url) self._gps_style = 1 self._full = true UIPackage.AddPackage("extend/majiang/chaozhou/ui/Extend_MJ_ChaoZhou") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") self._hu_tip = HuTipView.new(self) - self._view:GetChild('wanfa_text').text =room.room_config.people_num .. '人潮州 ' .. room.score_times .. '倍' - - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self:SetReconnentLaiziTips() - - self:PlayerChangeLineState() + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人潮州 ' .. room.score_times .. '倍' - if room.playing or room.curren_round > 0 then + self.LaiziBG = self._view:GetChild('n103') + self.LaiziBG.text = "鬼牌" + self.LaiziBG.visible = false + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectlaizi1') + self.Laizi2Btn = self._view:GetChild('selectlaizi2') + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self:SetReconnentLaiziTips() + + self:PlayerChangeLineState() + + if room.playing or room.curren_round > 0 then self:ReloadRoom() end end - - function M:SetReconnentLaiziTips() - local room=DataManager.CurrenRoom - if room.beforelaiziCardId and room.beforelaiziCardId>0 then - self:SetShowLaiZiProcess(room.beforelaiziCardId,room.laiziInfo[1],room.laiziInfo[2],false) - end + local room = DataManager.CurrenRoom + if room.beforelaiziCardId and room.beforelaiziCardId > 0 then + self:SetShowLaiZiProcess(room.beforelaiziCardId, room.laiziInfo[1], room.laiziInfo[2], false) + end end - -function M:SetLaiZiCard(btn,cardId) - btn.icon='ui://Main_Majiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..cardId +function M:SetLaiZiCard(btn, cardId) + btn.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId end - -function M:IsShowLaiZi(btn,isShow) - btn.visible=isShow +function M:IsShowLaiZi(btn, isShow) + btn.visible = isShow end - function M:HideAllLaiZiCard() - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self.LaiziBG.visible=false + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self.LaiziBG.visible = false end -function M:SetShowLaiZiProcess(beforeLaiziID,currentLaizi1ID,currentLaizi2ID,isShowAnim) - --zhongid=currentLaizi1ID - if isShowAnim==nil then isShowAnim=false end - - printlog("当前赋值结果为====>>>") - print(beforeLaiziID) - print(currentLaizi1ID) - print(currentLaizi2ID) - self:HideAllLaiZiCard() - self:SetLaiZiCard(self.selectLaiziBtn,beforeLaiziID) - self:SetLaiZiCard(self.Laizi1Btn,currentLaizi1ID) - if currentLaizi2ID then - self:SetLaiZiCard(self.Laizi2Btn,currentLaizi2ID) - end - - - if isShowAnim==true then - self:IsShowLaiZi(self.selectLaiziBtn,true) - coroutine.start( - function() - coroutine.wait(1) - self:HideAllLaiZiCard() - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - - end - ) - else - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - end - self.LaiziBG.visible=true -end +function M:SetShowLaiZiProcess(beforeLaiziID, currentLaizi1ID, currentLaizi2ID, isShowAnim) + --zhongid=currentLaizi1ID + if isShowAnim == nil then isShowAnim = false end + printlog("当前赋值结果为====>>>") + -- print(beforeLaiziID) + -- print(currentLaizi1ID) + -- print(currentLaizi2ID) + self:HideAllLaiZiCard() + self:SetLaiZiCard(self.selectLaiziBtn, beforeLaiziID) + self:SetLaiZiCard(self.Laizi1Btn, currentLaizi1ID) + if currentLaizi2ID then + self:SetLaiZiCard(self.Laizi2Btn, currentLaizi2ID) + end + + + if isShowAnim == true then + self:IsShowLaiZi(self.selectLaiziBtn, true) + coroutine.start( + function() + coroutine.wait(1) + self:HideAllLaiZiCard() + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + ) + else + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + self.LaiziBG.visible = true +end function M:UpdateRound() self._view:GetChild("tex_round1").text = self._room.curren_round @@ -122,58 +115,58 @@ function M:UpdateRound() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) end - return MJPlayerCardInfoView.new(view,self) + return MJPlayerCardInfoView.new(view, self) end function M:EventInit() - -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MainView.EventInit(self) + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info - local _gamectr = self._gamectr + local _gamectr = self._gamectr - _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) - local arg = {...} - self:SetShowLaiZiProcess(arg[1],arg[2],arg[3],arg[4]) + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4]) end) - _gamectr:AddEventListener(TX_GameEvent.SendCards,function( ... ) + _gamectr:AddEventListener(TX_GameEvent.SendCards, function(...) -- self:ShowHuTip() self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:UpdateHandCard() end end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = {...} + _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) + local arg = { ... } self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) @@ -187,11 +180,11 @@ function M:EventInit() info:UpdateHandCard(true) end) - local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -208,7 +201,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] -- self._tex_leftTime.text = arg[3] @@ -219,30 +212,30 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local weight = arg[2] self:__FangziTip(_tip, weight) end) - - _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + + _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] - local lose_seat = arg[2] - local win_card = arg[3] - local cards = arg[4] - local win_list = arg[5] - local index = self:GetPos(win_seat) - local info = self._player_card_info[index] + local lose_seat = arg[2] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] self:RemoveCursor() info:UpdateHandCard(true, true) - + local obj_win_card = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Btn_Card") obj_win_card.icon = "ui://Main_Majiang/202_" .. win_card obj_win_card:GetController("bg").selectedIndex = 1 @@ -261,84 +254,82 @@ function M:EventInit() if win_seat == lose_seat then url = "ui://Main_Majiang/eff_zimo" end - + local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - he:Center() - if _room.room_config.people_num==2 then - if win_seat ~= _room.self_player.seat then - he.scaleY = 0.4 - he.scaleX = 0.4 - he.x = he.width * 0.4 * 0.5 * -1 - he.y = he.height * 0.4 * 0.5 * -1 - end - end - - if win_seat == _room.self_player.seat then - printlog("自己位置=====") - he:Center() + he:Center() + if _room.room_config.people_num == 2 then + if win_seat ~= _room.self_player.seat then + he.scaleY = 0.4 + he.scaleX = 0.4 + he.x = he.width * 0.4 * 0.5 * -1 + he.y = he.height * 0.4 * 0.5 * -1 + end + end + + if win_seat == _room.self_player.seat then + printlog("自己位置=====") + he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then - printlog("自摸地址==========") + printlog("自摸地址==========") he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end - - - - --- - local isZiMo=win_seat==lose_seat - DataManager.CurrenRoom.isZiMoHu=isZiMo - local hu_sound = isZiMo and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) - printlog("声音====>>>",hu_sound) - self:PlaySound("ChaoZhou_MJ",player.self_user.sex, hu_sound) - - local pNode = info._view - local url = "eff_list1" + + + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) + printlog("声音====>>>", hu_sound) + self:PlaySound("ChaoZhou_MJ", player.self_user.sex, hu_sound) + + local pNode = info._view + local url = "eff_list1" local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChaoZhou/" .. url) he_list.touchable = false pNode:AddChild(he_list) he_list:Center() - + coroutine.start(function() - for i = 1 ,#win_list do - local tem = win_list[i] - if tem.type>0 and tem.type<32 then - local com_name = "he" .. tem.type - local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChaoZhou/" .. com_name) - coroutine.wait(0.3) - end - - end - - coroutine.wait(2) - obj_win_card:Dispose() - he:Dispose() - he_list:Dispose() - self._popEvent = true + for i = 1, #win_list do + local tem = win_list[i] + if tem.type > 0 and tem.type < 32 then + local com_name = "he" .. tem.type + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChaoZhou/" .. com_name) + coroutine.wait(0.3) + end + end + + coroutine.wait(2) + obj_win_card:Dispose() + he:Dispose() + he_list:Dispose() + self._popEvent = true end) - end) _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] --ViewUtil.PlaySound("ChaoZhou_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + coroutine.start(self.RunNiao, self, list, start_seat) end) - - - _gamectr:AddEventListener(TX_GameEvent.EventMa, function(...) - local arg = {...} + + + _gamectr:AddEventListener(TX_GameEvent.EventMa, function(...) + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] --ViewUtil.PlaySound("ChaoZhou_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) @@ -347,7 +338,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -365,11 +356,11 @@ function M:EventInit() self:RemoveCursor() if self._clearingView == nil then self._clearingView = EXClearingView.new(self._root_view) - coroutine.start(function() + coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() self._popEvent = true - end) + end) end if _room.curren_round ~= _room.room_config.round then @@ -387,7 +378,7 @@ function M:EventInit() end info:UpdateScore() info._view:GetChild("zhanji").visible = true - local num = data[i].hp_info.total_hp + local num = data[i].hp_info.total_hp if num > 0 then info._view:GetController("text_color").selectedIndex = 0 info._view:GetChild("text_jifen").text = "+" .. d2ad(num) @@ -405,7 +396,7 @@ function M:EventInit() self._clearingView = nil end) end - self._player_card_info[1]:ShowHuTip() + self._player_card_info[1]:ShowHuTip() end) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) @@ -413,7 +404,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -421,7 +412,7 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() - end) + end) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -429,21 +420,21 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() self:UpdateRound() self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 + self._state.selectedIndex = 1 self:__PiaoNiaoTip() end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 - end + end if seat == _room.self_player.seat then - if self._com_piao and _room.self_player.entrust then + if self._com_piao and _room.self_player.entrust then self._com_piao:Dispose() self._com_piao = nil _room.curren_round = _room.curren_round - 1 @@ -454,21 +445,21 @@ end function M:OutCard(card) if card ~= 0 then - printlog("当前出牌为===>>>"..card) + printlog("当前出牌为===>>>" .. card) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card, function() - local info = self._player_card_info[1] - self:RemoveCursor() - info:UpdateHandCard() + local info = self._player_card_info[1] + self:RemoveCursor() + info:UpdateHandCard() - info:UpdateOutCardList(nil, card, self._cursor) - self:PlaySound("ChaoZhou_MJ", self._room.self_player.self_user.sex,tostring(card)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - else - printlog("鬼牌不能出===>>>"..card) + info:UpdateOutCardList(nil, card, self._cursor) + self:PlaySound("ChaoZhou_MJ", self._room.self_player.self_user.sex, tostring(card)) + self:PlayMJSound("chupai.mp3") + -- self:ShowHuTip() + end) + else + printlog("鬼牌不能出===>>>" .. card) end end @@ -483,102 +474,96 @@ function M:__FangziTip(tip, weight) local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") _lit_fanzi:RemoveChildrenToPool() local _tlist = table.keys(tip.tip_map_type) - - if DataManager.CurrenRoom.room_config.must_hu and DataManager.CurrenRoom.room_config.must_hu==true then - local tip_hu = false - local count = #_tlist - - for i=1,count do - if tip.tip_map_id[i].type==6 then - tip_hu=true - end - end - - - for k=1,#_tlist do - - local td = tip.tip_map_type[_tlist[k]][1] - local url = "ui://Main_Majiang/Btn_fztip" - local td_weight = td.weight - if td_weight == 16 then td_weight = 8 end - if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end - if tip_hu==true then - if td.type==6 then - local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight - btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - end - - else - local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight - btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - end - - end - - if tip_hu==false then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - end - end) - end - - else - local tip_hu = false - local count = #_tlist - for k=1,#_tlist do - local td = tip.tip_map_type[_tlist[k]][1] - local url = "ui://Main_Majiang/Btn_fztip" - local td_weight = td.weight - if td_weight == 16 then td_weight = 8 end - if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end - local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight - btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - end - -- if not (tonumber(weight) >= 16) then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - end - end) - -- end - - - end - + if DataManager.CurrenRoom.room_config.must_hu and DataManager.CurrenRoom.room_config.must_hu == true then + local tip_hu = false + local count = #_tlist + + for i = 1, count do + if tip.tip_map_id[i].type == 6 then + tip_hu = true + end + end + + + for k = 1, #_tlist do + local td = tip.tip_map_type[_tlist[k]][1] + local url = "ui://Main_Majiang/Btn_fztip" + local td_weight = td.weight + if td_weight == 16 then td_weight = 8 end + if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end + if tip_hu == true then + if td.type == 6 then + local btn_t = _lit_fanzi:AddItemFromPool(url) + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight + btn_t.data = { tip, td } + btn_t.onClick:Add(self.__TipAction, self) + end + else + local btn_t = _lit_fanzi:AddItemFromPool(url) + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight + btn_t.data = { tip, td } + btn_t.onClick:Add(self.__TipAction, self) + end + end + + if tip_hu == false then + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") + -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") + _btn_pass.onClick:Set(function() + if tonumber(weight) >= 8 then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end + end) + end + else + local tip_hu = false + local count = #_tlist + for k = 1, #_tlist do + local td = tip.tip_map_type[_tlist[k]][1] + local url = "ui://Main_Majiang/Btn_fztip" + local td_weight = td.weight + if td_weight == 16 then td_weight = 8 end + if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end + local btn_t = _lit_fanzi:AddItemFromPool(url) + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight + btn_t.data = { tip, td } + btn_t.onClick:Add(self.__TipAction, self) + end + + -- if not (tonumber(weight) >= 16) then + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") + -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") + _btn_pass.onClick:Set(function() + if tonumber(weight) >= 8 then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end + end) + -- end + end + self._view:AddChild(_chipeng_tip) _chipeng_tip:Center() @@ -620,20 +605,21 @@ function M:_ChiView(tiplist, callback) local item_choose = list_choose:AddItemFromPool() item_choose:GetController("type").selectedIndex = 0 for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", "202_"..tiplist[i].card) + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. tiplist[i].card) end item_choose.onClick:Add(function() callback(tiplist[i].id) end) end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end function M:OnFangziAction(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -643,16 +629,15 @@ function M:OnFangziAction(...) local pNode = info._mask_liangpai local effect = UIPackage.CreateObject("Extend_MJ_ChaoZhou", "FzEffect") if fz.type == FZType.Peng then - self:PlaySound("ChaoZhou_MJ", player.self_user.sex,"peng"..math.random(1, 3)) + self:PlaySound("ChaoZhou_MJ", player.self_user.sex, "peng" .. math.random(1, 3)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") else - - self:PlaySound("ChaoZhou_MJ", player.self_user.sex,"gang"..math.random(1, 2)) + self:PlaySound("ChaoZhou_MJ", player.self_user.sex, "gang" .. math.random(1, 2)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") end effect.touchable = false effect:GetTransition("t2"):Play() @@ -676,13 +661,13 @@ end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_ChaoZhou","Panel_Birds") + self._niao_View = UIPackage.CreateObject("Extend_MJ_ChaoZhou", "Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do + for i = 1, #list do --添加背面的麻將 local item = list_niao_card:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") @@ -694,7 +679,7 @@ function M:RunNiao(list, start_seat) local card = list[i].card coroutine.wait(0.3) item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_Majiang", "201_"..card) + item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() @@ -719,17 +704,17 @@ end -- end function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end function M:ReloadRoom(bskip) @@ -742,36 +727,36 @@ function M:ReloadRoom(bskip) -- end if bskip == nil or bskip == false then - if not room.playing then - self._state.selectedIndex = 2 - else - self._state.selectedIndex = 1 - self._room._reload_flag = true - end + if not room.playing then + self._state.selectedIndex = 2 + else + self._state.selectedIndex = 1 + self._room._reload_flag = true + end end - + for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end - info:UpdateHandCard() + info:UpdateHandCard() local head_info = self._player_info[self:GetPos(p.seat)] head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true - local num = p.total_hp or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = d2ad(num) - end + local num = p.total_hp or 0 + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = d2ad(num) + end if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() @@ -785,34 +770,34 @@ function M:ReloadRoom(bskip) -- self._player_info[self:GetPos(p.seat)]:Ready(true) -- end if bskip == nil or bskip == false then - if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) - end - end - if p.piao_niao~=nil and p.piao_niao > 0 then + if p.ready and room.playing == false then + self._player_info[self:GetPos(p.seat)]:Ready(true) + end + end + if p.piao_niao ~= nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end -- self:ShowHuTip() - + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() - end + end end function M:PlayerChangeLineState() - -- local isOutCard = true - -- local str = "玩家 " - -- for _ , player in ipairs(self._room.player_list) do - -- if player.line_state == 0 then - -- isOutCard = false - -- end - -- end - -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard + -- local isOutCard = true + -- local str = "玩家 " + -- for _ , player in ipairs(self._room.player_list) do + -- if player.line_state == 0 then + -- isOutCard = false + -- end + -- end + -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard end function M:UpdateCardBox(seat) @@ -846,4 +831,4 @@ function M:Destroy() UIPackage.RemovePackage("extend/majiang/chaozhou/ui/Extend_MJ_ChaoZhou") end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/chaozhou/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/chaozhou/ExtendConfig.lua index eee70a45..6c5c8149 100644 --- a/lua_probject/extend_project/extend/majiang/chaozhou/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/chaozhou/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,46 +45,46 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - printlog("初始化房间数据====>>>") - pt(_tableInfo) - printlog(_tableInfo.laiziCard) - printlog(_tableInfo.laiziCard2) - printlog(_tableInfo.laiziCardBefore) - printlog(_tableInfo.laiziCard2Before) - - room.laiziInfo={} - if _tableInfo.laiziCardBefore>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard) - if _tableInfo.laiziCard2>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard2) - end - room.beforelaiziCardId=_tableInfo.laiziCardBefore - else - room.laiziInfo=nil - end + printlog("初始化房间数据====>>>") + pt(_tableInfo) + printlog(_tableInfo.laiziCard) + printlog(_tableInfo.laiziCard2) + printlog(_tableInfo.laiziCardBefore) + printlog(_tableInfo.laiziCard2Before) + + room.laiziInfo = {} + if _tableInfo.laiziCardBefore > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard) + if _tableInfo.laiziCard2 > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard2) + end + room.beforelaiziCardId = _tableInfo.laiziCardBefore + else + room.laiziInfo = nil + end local _config = _tableInfo["config"] - pt(_config) + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -93,10 +93,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -107,23 +107,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -147,7 +147,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -156,21 +156,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -186,4 +186,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/chaozhou/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/chaozhou/MJPlayerSelfCardInfoView.lua index 51ef5dd2..ad01283f 100644 --- a/lua_probject/extend_project/extend/majiang/chaozhou/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/chaozhou/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -16,16 +16,16 @@ function M.new(view,mainView) end function M:ShowHuTip(card_list) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -34,32 +34,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -72,7 +68,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -91,7 +88,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -108,7 +105,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -116,17 +112,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -159,17 +155,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -189,6 +185,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -203,10 +200,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/chaozhougui/EXMainView.lua b/lua_probject/extend_project/extend/majiang/chaozhougui/EXMainView.lua index 85cf20a4..4cbe1951 100644 --- a/lua_probject/extend_project/extend/majiang/chaozhougui/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/chaozhougui/EXMainView.lua @@ -10,8 +10,8 @@ local M = {} --- Create a new ZZ_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "MainView" self.asset_group = "ChaoZhouGui_MJ" self:init() @@ -25,96 +25,89 @@ function M:InitView(url) self._gps_style = 1 self._full = true UIPackage.AddPackage("extend/majiang/chaozhougui/ui/Extend_MJ_ChaoZhouGui") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") self._hu_tip = HuTipView.new(self) - self._view:GetChild('wanfa_text').text =room.room_config.people_num .. '人潮鬼 ' .. room.score_times .. '倍' - - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self:SetReconnentLaiziTips() - - self:PlayerChangeLineState() + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人潮鬼 ' .. room.score_times .. '倍' - if room.playing or room.curren_round > 0 then + self.LaiziBG = self._view:GetChild('n103') + self.LaiziBG.text = "鬼牌" + self.LaiziBG.visible = false + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectlaizi1') + self.Laizi2Btn = self._view:GetChild('selectlaizi2') + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self:SetReconnentLaiziTips() + + self:PlayerChangeLineState() + + if room.playing or room.curren_round > 0 then self:ReloadRoom() end end - - function M:SetReconnentLaiziTips() - local room=DataManager.CurrenRoom - if room.beforelaiziCardId and room.beforelaiziCardId>0 then - self:SetShowLaiZiProcess(room.beforelaiziCardId,room.laiziInfo[1],room.laiziInfo[2],false) - end + local room = DataManager.CurrenRoom + if room.beforelaiziCardId and room.beforelaiziCardId > 0 then + self:SetShowLaiZiProcess(room.beforelaiziCardId, room.laiziInfo[1], room.laiziInfo[2], false) + end end - -function M:SetLaiZiCard(btn,cardId) - btn.icon='ui://Main_Majiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..cardId +function M:SetLaiZiCard(btn, cardId) + btn.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId end - -function M:IsShowLaiZi(btn,isShow) - btn.visible=isShow +function M:IsShowLaiZi(btn, isShow) + btn.visible = isShow end - function M:HideAllLaiZiCard() - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self.LaiziBG.visible=false + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self.LaiziBG.visible = false end -function M:SetShowLaiZiProcess(beforeLaiziID,currentLaizi1ID,currentLaizi2ID,isShowAnim) - --zhongid=currentLaizi1ID - if isShowAnim==nil then isShowAnim=false end - - printlog("当前赋值结果为====>>>") - print(beforeLaiziID) - print(currentLaizi1ID) - print(currentLaizi2ID) - self:HideAllLaiZiCard() - self:SetLaiZiCard(self.selectLaiziBtn,beforeLaiziID) - self:SetLaiZiCard(self.Laizi1Btn,currentLaizi1ID) - if currentLaizi2ID then - self:SetLaiZiCard(self.Laizi2Btn,currentLaizi2ID) - end - - - if isShowAnim==true then - self:IsShowLaiZi(self.selectLaiziBtn,true) - coroutine.start( - function() - coroutine.wait(1) - self:HideAllLaiZiCard() - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - - end - ) - else - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - end - self.LaiziBG.visible=true -end +function M:SetShowLaiZiProcess(beforeLaiziID, currentLaizi1ID, currentLaizi2ID, isShowAnim) + --zhongid=currentLaizi1ID + if isShowAnim == nil then isShowAnim = false end + printlog("当前赋值结果为====>>>") + -- print(beforeLaiziID) + -- print(currentLaizi1ID) + -- print(currentLaizi2ID) + self:HideAllLaiZiCard() + self:SetLaiZiCard(self.selectLaiziBtn, beforeLaiziID) + self:SetLaiZiCard(self.Laizi1Btn, currentLaizi1ID) + if currentLaizi2ID then + self:SetLaiZiCard(self.Laizi2Btn, currentLaizi2ID) + end + + + if isShowAnim == true then + self:IsShowLaiZi(self.selectLaiziBtn, true) + coroutine.start( + function() + coroutine.wait(1) + self:HideAllLaiZiCard() + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + ) + else + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + self.LaiziBG.visible = true +end function M:UpdateRound() self._view:GetChild("tex_round1").text = self._room.curren_round @@ -122,58 +115,58 @@ function M:UpdateRound() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) end - return MJPlayerCardInfoView.new(view,self) + return MJPlayerCardInfoView.new(view, self) end function M:EventInit() - -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MainView.EventInit(self) + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info - local _gamectr = self._gamectr + local _gamectr = self._gamectr - _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) - local arg = {...} - self:SetShowLaiZiProcess(arg[1],arg[2],arg[3],arg[4]) + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4]) end) - _gamectr:AddEventListener(TX_GameEvent.SendCards,function( ... ) + _gamectr:AddEventListener(TX_GameEvent.SendCards, function(...) -- self:ShowHuTip() self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:UpdateHandCard() end end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = {...} + _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) + local arg = { ... } self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) @@ -187,11 +180,11 @@ function M:EventInit() info:UpdateHandCard(true) end) - local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -208,7 +201,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] -- self._tex_leftTime.text = arg[3] @@ -219,30 +212,30 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local weight = arg[2] self:__FangziTip(_tip, weight) end) - - _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + + _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] - local lose_seat = arg[2] - local win_card = arg[3] - local cards = arg[4] - local win_list = arg[5] - local index = self:GetPos(win_seat) - local info = self._player_card_info[index] + local lose_seat = arg[2] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] self:RemoveCursor() info:UpdateHandCard(true, true) - + local obj_win_card = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Btn_Card") obj_win_card.icon = "ui://Main_Majiang/202_" .. win_card obj_win_card:GetController("bg").selectedIndex = 1 @@ -261,84 +254,82 @@ function M:EventInit() if win_seat == lose_seat then url = "ui://Main_Majiang/eff_zimo" end - + local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - he:Center() - if _room.room_config.people_num==2 then - if win_seat ~= _room.self_player.seat then - he.scaleY = 0.4 - he.scaleX = 0.4 - he.x = he.width * 0.4 * 0.5 * -1 - he.y = he.height * 0.4 * 0.5 * -1 - end - end - - if win_seat == _room.self_player.seat then - printlog("自己位置=====") - he:Center() + he:Center() + if _room.room_config.people_num == 2 then + if win_seat ~= _room.self_player.seat then + he.scaleY = 0.4 + he.scaleX = 0.4 + he.x = he.width * 0.4 * 0.5 * -1 + he.y = he.height * 0.4 * 0.5 * -1 + end + end + + if win_seat == _room.self_player.seat then + printlog("自己位置=====") + he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then - printlog("自摸地址==========") + printlog("自摸地址==========") he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end - - - - --- - local isZiMo=win_seat==lose_seat - DataManager.CurrenRoom.isZiMoHu=isZiMo - local hu_sound = isZiMo and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) - printlog("声音====>>>",hu_sound) - self:PlaySound("ChaoZhouGui_MJ",player.self_user.sex, hu_sound) - - local pNode = info._view - local url = "eff_list1" + + + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) + printlog("声音====>>>", hu_sound) + self:PlaySound("ChaoZhouGui_MJ", player.self_user.sex, hu_sound) + + local pNode = info._view + local url = "eff_list1" local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChaoZhouGui/" .. url) he_list.touchable = false pNode:AddChild(he_list) he_list:Center() - + coroutine.start(function() - for i = 1 ,#win_list do - local tem = win_list[i] - if tem.type>0 and tem.type<32 then - local com_name = "he" .. tem.type - local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChaoZhouGui/" .. com_name) - coroutine.wait(0.3) - end - - end - - coroutine.wait(2) - obj_win_card:Dispose() - he:Dispose() - he_list:Dispose() - self._popEvent = true + for i = 1, #win_list do + local tem = win_list[i] + if tem.type > 0 and tem.type < 32 then + local com_name = "he" .. tem.type + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChaoZhouGui/" .. com_name) + coroutine.wait(0.3) + end + end + + coroutine.wait(2) + obj_win_card:Dispose() + he:Dispose() + he_list:Dispose() + self._popEvent = true end) - end) _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] --ViewUtil.PlaySound("ChaoZhou_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + coroutine.start(self.RunNiao, self, list, start_seat) end) - - - _gamectr:AddEventListener(TX_GameEvent.EventMa, function(...) - local arg = {...} + + + _gamectr:AddEventListener(TX_GameEvent.EventMa, function(...) + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] --ViewUtil.PlaySound("ChaoZhou_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) @@ -347,7 +338,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -365,11 +356,11 @@ function M:EventInit() self:RemoveCursor() if self._clearingView == nil then self._clearingView = EXClearingView.new(self._root_view) - coroutine.start(function() + coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() self._popEvent = true - end) + end) end if _room.curren_round ~= _room.room_config.round then @@ -387,7 +378,7 @@ function M:EventInit() end info:UpdateScore() info._view:GetChild("zhanji").visible = true - local num = data[i].hp_info.total_hp + local num = data[i].hp_info.total_hp if num > 0 then info._view:GetController("text_color").selectedIndex = 0 info._view:GetChild("text_jifen").text = "+" .. d2ad(num) @@ -405,7 +396,7 @@ function M:EventInit() self._clearingView = nil end) end - self._player_card_info[1]:ShowHuTip() + self._player_card_info[1]:ShowHuTip() end) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) @@ -413,7 +404,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -421,7 +412,7 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() - end) + end) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -429,21 +420,21 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() self:UpdateRound() self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 + self._state.selectedIndex = 1 self:__PiaoNiaoTip() end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 - end + end if seat == _room.self_player.seat then - if self._com_piao and _room.self_player.entrust then + if self._com_piao and _room.self_player.entrust then self._com_piao:Dispose() self._com_piao = nil _room.curren_round = _room.curren_round - 1 @@ -454,21 +445,21 @@ end function M:OutCard(card) if card ~= 0 then - printlog("当前出牌为===>>>"..card) + printlog("当前出牌为===>>>" .. card) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card, function() - local info = self._player_card_info[1] - self:RemoveCursor() - info:UpdateHandCard() + local info = self._player_card_info[1] + self:RemoveCursor() + info:UpdateHandCard() - info:UpdateOutCardList(nil, card, self._cursor) - self:PlaySound("ChaoZhouGui_MJ", self._room.self_player.self_user.sex,tostring(card)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - else - printlog("鬼牌不能出===>>>"..card) + info:UpdateOutCardList(nil, card, self._cursor) + self:PlaySound("ChaoZhouGui_MJ", self._room.self_player.self_user.sex, tostring(card)) + self:PlayMJSound("chupai.mp3") + -- self:ShowHuTip() + end) + else + printlog("鬼牌不能出===>>>" .. card) end end @@ -483,102 +474,96 @@ function M:__FangziTip(tip, weight) local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") _lit_fanzi:RemoveChildrenToPool() local _tlist = table.keys(tip.tip_map_type) - - if DataManager.CurrenRoom.room_config.must_hu and DataManager.CurrenRoom.room_config.must_hu==true then - local tip_hu = false - local count = #_tlist - - for i=1,count do - if tip.tip_map_id[i].type==6 then - tip_hu=true - end - end - - - for k=1,#_tlist do - - local td = tip.tip_map_type[_tlist[k]][1] - local url = "ui://Main_Majiang/Btn_fztip" - local td_weight = td.weight - if td_weight == 16 then td_weight = 8 end - if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end - if tip_hu==true then - if td.type==6 then - local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight - btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - end - - else - local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight - btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - end - - end - - if tip_hu==false then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - end - end) - end - - else - local tip_hu = false - local count = #_tlist - for k=1,#_tlist do - local td = tip.tip_map_type[_tlist[k]][1] - local url = "ui://Main_Majiang/Btn_fztip" - local td_weight = td.weight - if td_weight == 16 then td_weight = 8 end - if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end - local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight - btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - end - -- if not (tonumber(weight) >= 16) then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - end - end) - -- end - - - end - + if DataManager.CurrenRoom.room_config.must_hu and DataManager.CurrenRoom.room_config.must_hu == true then + local tip_hu = false + local count = #_tlist + + for i = 1, count do + if tip.tip_map_id[i].type == 6 then + tip_hu = true + end + end + + + for k = 1, #_tlist do + local td = tip.tip_map_type[_tlist[k]][1] + local url = "ui://Main_Majiang/Btn_fztip" + local td_weight = td.weight + if td_weight == 16 then td_weight = 8 end + if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end + if tip_hu == true then + if td.type == 6 then + local btn_t = _lit_fanzi:AddItemFromPool(url) + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight + btn_t.data = { tip, td } + btn_t.onClick:Add(self.__TipAction, self) + end + else + local btn_t = _lit_fanzi:AddItemFromPool(url) + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight + btn_t.data = { tip, td } + btn_t.onClick:Add(self.__TipAction, self) + end + end + + if tip_hu == false then + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") + -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") + _btn_pass.onClick:Set(function() + if tonumber(weight) >= 8 then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end + end) + end + else + local tip_hu = false + local count = #_tlist + for k = 1, #_tlist do + local td = tip.tip_map_type[_tlist[k]][1] + local url = "ui://Main_Majiang/Btn_fztip" + local td_weight = td.weight + if td_weight == 16 then td_weight = 8 end + if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end + local btn_t = _lit_fanzi:AddItemFromPool(url) + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight + btn_t.data = { tip, td } + btn_t.onClick:Add(self.__TipAction, self) + end + + -- if not (tonumber(weight) >= 16) then + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") + -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") + _btn_pass.onClick:Set(function() + if tonumber(weight) >= 8 then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end + end) + -- end + end + self._view:AddChild(_chipeng_tip) _chipeng_tip:Center() @@ -620,20 +605,21 @@ function M:_ChiView(tiplist, callback) local item_choose = list_choose:AddItemFromPool() item_choose:GetController("type").selectedIndex = 0 for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", "202_"..tiplist[i].card) + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. tiplist[i].card) end item_choose.onClick:Add(function() callback(tiplist[i].id) end) end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end function M:OnFangziAction(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -643,16 +629,15 @@ function M:OnFangziAction(...) local pNode = info._mask_liangpai local effect = UIPackage.CreateObject("Extend_MJ_ChaoZhouGui", "FzEffect") if fz.type == FZType.Peng then - self:PlaySound("ChaoZhouGui_MJ", player.self_user.sex,"peng"..math.random(1, 3)) + self:PlaySound("ChaoZhouGui_MJ", player.self_user.sex, "peng" .. math.random(1, 3)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") else - - self:PlaySound("ChaoZhouGui_MJ", player.self_user.sex,"gang"..math.random(1, 2)) + self:PlaySound("ChaoZhouGui_MJ", player.self_user.sex, "gang" .. math.random(1, 2)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") end effect.touchable = false effect:GetTransition("t2"):Play() @@ -676,13 +661,13 @@ end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_ChaoZhouGui","Panel_Birds") + self._niao_View = UIPackage.CreateObject("Extend_MJ_ChaoZhouGui", "Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do + for i = 1, #list do --添加背面的麻將 local item = list_niao_card:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") @@ -694,7 +679,7 @@ function M:RunNiao(list, start_seat) local card = list[i].card coroutine.wait(0.3) item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_Majiang", "201_"..card) + item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() @@ -719,17 +704,17 @@ end -- end function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end function M:ReloadRoom(bskip) @@ -742,36 +727,36 @@ function M:ReloadRoom(bskip) -- end if bskip == nil or bskip == false then - if not room.playing then - self._state.selectedIndex = 2 - else - self._state.selectedIndex = 1 - self._room._reload_flag = true - end + if not room.playing then + self._state.selectedIndex = 2 + else + self._state.selectedIndex = 1 + self._room._reload_flag = true + end end - + for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end - info:UpdateHandCard() + info:UpdateHandCard() local head_info = self._player_info[self:GetPos(p.seat)] head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true - local num = p.total_hp or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = d2ad(num) - end + local num = p.total_hp or 0 + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = d2ad(num) + end if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() @@ -785,34 +770,34 @@ function M:ReloadRoom(bskip) -- self._player_info[self:GetPos(p.seat)]:Ready(true) -- end if bskip == nil or bskip == false then - if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) - end - end - if p.piao_niao~=nil and p.piao_niao > 0 then + if p.ready and room.playing == false then + self._player_info[self:GetPos(p.seat)]:Ready(true) + end + end + if p.piao_niao ~= nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end -- self:ShowHuTip() - + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() - end + end end function M:PlayerChangeLineState() - -- local isOutCard = true - -- local str = "玩家 " - -- for _ , player in ipairs(self._room.player_list) do - -- if player.line_state == 0 then - -- isOutCard = false - -- end - -- end - -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard + -- local isOutCard = true + -- local str = "玩家 " + -- for _ , player in ipairs(self._room.player_list) do + -- if player.line_state == 0 then + -- isOutCard = false + -- end + -- end + -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard end function M:UpdateCardBox(seat) @@ -846,4 +831,4 @@ function M:Destroy() UIPackage.RemovePackage("extend/majiang/chaozhougui/ui/Extend_MJ_ChaoZhouGui") end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/chaozhougui/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/chaozhougui/ExtendConfig.lua index 773f5f08..5909877e 100644 --- a/lua_probject/extend_project/extend/majiang/chaozhougui/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/chaozhougui/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,46 +45,46 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - printlog("初始化房间数据====>>>") - pt(_tableInfo) - printlog(_tableInfo.laiziCard) - printlog(_tableInfo.laiziCard2) - printlog(_tableInfo.laiziCardBefore) - printlog(_tableInfo.laiziCard2Before) - - room.laiziInfo={} - if _tableInfo.laiziCardBefore>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard) - if _tableInfo.laiziCard2>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard2) - end - room.beforelaiziCardId=_tableInfo.laiziCardBefore - else - room.laiziInfo=nil - end + printlog("初始化房间数据====>>>") + pt(_tableInfo) + printlog(_tableInfo.laiziCard) + printlog(_tableInfo.laiziCard2) + printlog(_tableInfo.laiziCardBefore) + printlog(_tableInfo.laiziCard2Before) + + room.laiziInfo = {} + if _tableInfo.laiziCardBefore > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard) + if _tableInfo.laiziCard2 > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard2) + end + room.beforelaiziCardId = _tableInfo.laiziCardBefore + else + room.laiziInfo = nil + end local _config = _tableInfo["config"] - pt(_config) + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -93,10 +93,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -107,23 +107,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -147,7 +147,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -156,21 +156,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -186,4 +186,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/chaozhougui/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/chaozhougui/MJPlayerSelfCardInfoView.lua index 51ef5dd2..ad01283f 100644 --- a/lua_probject/extend_project/extend/majiang/chaozhougui/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/chaozhougui/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -16,16 +16,16 @@ function M.new(view,mainView) end function M:ShowHuTip(card_list) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -34,32 +34,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -72,7 +68,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -91,7 +88,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -108,7 +105,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -116,17 +112,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -159,17 +155,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -189,6 +185,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -203,10 +200,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/fuzhou/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/fuzhou/ExtendConfig.lua index 76e867c0..0f1694cb 100644 --- a/lua_probject/extend_project/extend/majiang/fuzhou/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/fuzhou/ExtendConfig.lua @@ -140,7 +140,7 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser diff --git a/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua index 72d1d092..138cb3b5 100644 --- a/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -17,16 +17,16 @@ end function M:ShowHuTip(card_list) printlog("ShowHuTip") - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -35,32 +35,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -73,7 +69,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -92,7 +89,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -109,7 +106,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -117,17 +113,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -160,17 +156,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -190,6 +186,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -204,10 +201,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/gejiu/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/gejiu/ExtendConfig.lua index 96c86352..c70acd0b 100644 --- a/lua_probject/extend_project/extend/majiang/gejiu/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/gejiu/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 33 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 33 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,30 +45,30 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - + local _config = _tableInfo["config"] - - pt(_config) + + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -77,10 +77,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -91,23 +91,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -131,7 +131,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -140,21 +140,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -170,4 +170,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/gejiu/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/gejiu/MJPlayerSelfCardInfoView.lua index 72d1d092..138cb3b5 100644 --- a/lua_probject/extend_project/extend/majiang/gejiu/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/gejiu/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -17,16 +17,16 @@ end function M:ShowHuTip(card_list) printlog("ShowHuTip") - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -35,32 +35,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -73,7 +69,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -92,7 +89,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -109,7 +106,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -117,17 +113,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -160,17 +156,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -190,6 +186,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -204,10 +201,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua index 681f4cf3..cda3fd88 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,24 +45,24 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - - local reload = s2croom["reload"] + local room = DataManager.CurrenRoom + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] local _config = _tableInfo["config"] @@ -74,10 +74,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -88,23 +88,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -128,7 +128,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -137,21 +137,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -167,4 +167,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua index 68453705..37f180cb 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -16,7 +16,8 @@ function M.new(view,mainView) end function M:ShowHuTip(card_list) - local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then table.insert(tingList, 412) end @@ -38,7 +39,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -57,7 +59,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -81,17 +83,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -124,17 +126,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 412) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -154,6 +156,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -168,10 +171,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/jinxi/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/jinxi/ExtendConfig.lua index 66751b58..21f02a97 100644 --- a/lua_probject/extend_project/extend/majiang/jinxi/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/jinxi/ExtendConfig.lua @@ -140,7 +140,7 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser diff --git a/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua index 72d1d092..138cb3b5 100644 --- a/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -17,16 +17,16 @@ end function M:ShowHuTip(card_list) printlog("ShowHuTip") - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -35,32 +35,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -73,7 +69,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -92,7 +89,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -109,7 +106,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -117,17 +113,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -160,17 +156,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -190,6 +186,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -204,10 +201,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXGameController.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXGameController.lua index 28ffee6c..6564bb0d 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXGameController.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/EXGameController.lua @@ -121,7 +121,7 @@ function M:OnEventSendCards(evt_data) _room.jing = jing self._cacheEvent:Enqueue(function() _room.banker_seat = seat - print("========================fuzhijing") + -- print("========================fuzhijing") for i = 1, #_room.player_list do _room.player_list[i].hand_left_count = 13 _room.player_list[i].fz_list = {} @@ -275,7 +275,7 @@ function M:OnEventFzAction(evt_data) end function M:OnEventHu(evt_data) - print("===========================OnEventHu") + -- print("===========================OnEventHu") local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua index 9e416d36..c56feeb1 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua @@ -315,7 +315,7 @@ function M:EventInit() local tem = win_list[i] if tem.type > 0 and tem.type < 32 then local com_name = "he" .. tem.type - print("===================================com_name", com_name) + -- print("===================================com_name", com_name) local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_LiChuan/" .. com_name) coroutine.wait(0.3) end diff --git a/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua index 172308fb..45655bfc 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua @@ -109,7 +109,7 @@ function M:FillRoomData(s2croom) p.fz_list[#p.fz_list + 1] = fz end if not playing and room.curren_round > 0 then - print("=======================在此进入") + -- print("=======================在此进入") self.GetGameController():PlayerReady() end end @@ -141,7 +141,7 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser diff --git a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua index 6dbac6b3..4a026c2c 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua @@ -110,7 +110,7 @@ function M:UpdateHandCard(getcard, mp) end function M:__OnClickHandCard(context) - print("==========================__OnClickHandCard") + -- print("==========================__OnClickHandCard") local button = context.sender local _carViewList = self._carViewList local refresh = true @@ -168,7 +168,7 @@ function M:__OnDragEnd(context) local card = button.data local _room = DataManager.CurrenRoom - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false diff --git a/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua index 2294d676..09a9329c 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua @@ -109,7 +109,6 @@ function M:FillRoomData(s2croom) p.fz_list[#p.fz_list + 1] = fz end if not playing and room.curren_round > 0 then - print("=======================================自动开始") self.GetGameController():PlayerReady() end end @@ -141,7 +140,7 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser diff --git a/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua index 74c9086d..138cb3b5 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua @@ -166,7 +166,7 @@ function M:__OnDragEnd(context) local card = button.data local _room = DataManager.CurrenRoom - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false diff --git a/lua_probject/extend_project/extend/majiang/qizhiba/EXMainView.lua b/lua_probject/extend_project/extend/majiang/qizhiba/EXMainView.lua index fca9e309..40fc3186 100644 --- a/lua_probject/extend_project/extend/majiang/qizhiba/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/qizhiba/EXMainView.lua @@ -10,8 +10,8 @@ local M = {} --- Create a new ZZ_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "MainView" self.asset_group = "QiZhiBa_MJ" self:init() @@ -25,96 +25,89 @@ function M:InitView(url) self._gps_style = 1 self._full = true UIPackage.AddPackage("extend/majiang/qizhiba/ui/Extend_MJ_QiZhiBa") - MJMainView.InitView(self,"ui://Main_PokeMaJiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_PokeMaJiang/Main_" .. room.room_config.people_num .. "_s2") self._hu_tip = HuTipView.new(self) - self._view:GetChild('wanfa_text').text =room.room_config.people_num .. '人七支八 ' .. room.score_times .. '倍' - - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self:SetReconnentLaiziTips() - - self:PlayerChangeLineState() + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人七支八 ' .. room.score_times .. '倍' - if room.playing or room.curren_round > 0 then + self.LaiziBG = self._view:GetChild('n103') + self.LaiziBG.text = "鬼牌" + self.LaiziBG.visible = false + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectlaizi1') + self.Laizi2Btn = self._view:GetChild('selectlaizi2') + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self:SetReconnentLaiziTips() + + self:PlayerChangeLineState() + + if room.playing or room.curren_round > 0 then self:ReloadRoom() end end - - function M:SetReconnentLaiziTips() - local room=DataManager.CurrenRoom - if room.laiziInfo and room.laiziInfo[3] and tonumber(room.laiziInfo[3])>0 then - self:SetShowLaiZiProcess(room.laiziInfo[3],room.laiziInfo[3],0,false) - end + local room = DataManager.CurrenRoom + if room.laiziInfo and room.laiziInfo[3] and tonumber(room.laiziInfo[3]) > 0 then + self:SetShowLaiZiProcess(room.laiziInfo[3], room.laiziInfo[3], 0, false) + end end - -function M:SetLaiZiCard(btn,cardId) - btn.icon='ui://Main_PokeMaJiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..cardId +function M:SetLaiZiCard(btn, cardId) + btn.icon = 'ui://Main_PokeMaJiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId end - -function M:IsShowLaiZi(btn,isShow) - btn.visible=isShow +function M:IsShowLaiZi(btn, isShow) + btn.visible = isShow end - function M:HideAllLaiZiCard() - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self.LaiziBG.visible=false + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self.LaiziBG.visible = false end -function M:SetShowLaiZiProcess(beforeLaiziID,currentLaizi1ID,currentLaizi2ID,isShowAnim) - --zhongid=currentLaizi1ID - if isShowAnim==nil then isShowAnim=false end - - printlog("当前赋值结果为====>>>") - print(beforeLaiziID) - print(currentLaizi1ID) - print(currentLaizi2ID) - self:HideAllLaiZiCard() - self:SetLaiZiCard(self.selectLaiziBtn,beforeLaiziID) - self:SetLaiZiCard(self.Laizi1Btn,currentLaizi1ID) - if currentLaizi2ID>0 then - self:SetLaiZiCard(self.Laizi2Btn,currentLaizi2ID) - end - - - if isShowAnim==true then - self:IsShowLaiZi(self.selectLaiziBtn,true) - coroutine.start( - function() - coroutine.wait(1) - self:HideAllLaiZiCard() - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID>0 then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - - end - ) - else - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID>0 then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - end - self.LaiziBG.visible=true -end +function M:SetShowLaiZiProcess(beforeLaiziID, currentLaizi1ID, currentLaizi2ID, isShowAnim) + --zhongid=currentLaizi1ID + if isShowAnim == nil then isShowAnim = false end + printlog("当前赋值结果为====>>>") + -- print(beforeLaiziID) + -- print(currentLaizi1ID) + -- print(currentLaizi2ID) + self:HideAllLaiZiCard() + self:SetLaiZiCard(self.selectLaiziBtn, beforeLaiziID) + self:SetLaiZiCard(self.Laizi1Btn, currentLaizi1ID) + if currentLaizi2ID > 0 then + self:SetLaiZiCard(self.Laizi2Btn, currentLaizi2ID) + end + + + if isShowAnim == true then + self:IsShowLaiZi(self.selectLaiziBtn, true) + coroutine.start( + function() + coroutine.wait(1) + self:HideAllLaiZiCard() + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID > 0 then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + ) + else + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID > 0 then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + self.LaiziBG.visible = true +end function M:UpdateRound() self._view:GetChild("tex_round1").text = self._room.curren_round @@ -122,60 +115,60 @@ function M:UpdateRound() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) end - return MJPlayerCardInfoView.new(view,self) + return MJPlayerCardInfoView.new(view, self) end function M:EventInit() - -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MainView.EventInit(self) + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_PokeMaJiang", "Gcm_OutCard") local _player_info = self._player_info - local _gamectr = self._gamectr + local _gamectr = self._gamectr - _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) - local arg = {...} - self:SetShowLaiZiProcess(arg[1],arg[2],arg[3],arg[4]) + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4]) end) - _gamectr:AddEventListener(TX_GameEvent.HuTipsAction, function(...) - self._hu_tip:HideHuTipsPanel() + _gamectr:AddEventListener(TX_GameEvent.HuTipsAction, function(...) + self._hu_tip:HideHuTipsPanel() end) - - _gamectr:AddEventListener(TX_GameEvent.SendCards,function( ... ) + + _gamectr:AddEventListener(TX_GameEvent.SendCards, function(...) -- self:ShowHuTip() self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:UpdateHandCard() end end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = {...} + _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) + local arg = { ... } self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) @@ -189,11 +182,11 @@ function M:EventInit() info:UpdateHandCard(true) end) - local _gcm_outcard_url ="ui://Main_PokeMaJiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_PokeMaJiang/Gcm_OutCard" _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -202,7 +195,7 @@ function M:EventInit() info:UpdateHandCard() local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url) info:UpdateOutCardList(outcard, card, self._cursor) - local cardAudio=string.sub(card,2) + local cardAudio = string.sub(card, 2) self:PlaySound("QiZhiBa_MJ", p.self_user.sex, tostring(cardAudio)) self:PlayMJSound("chupai.mp3") if seat == _room.self_player.seat then @@ -211,7 +204,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] -- self._tex_leftTime.text = arg[3] @@ -222,26 +215,26 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - arg={...} + arg = { ... } local _tip = arg[1] - self:__FangziTip(_tip) + self:__FangziTip(_tip) end) - - _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + + _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] - local lose_seat = arg[2] - local win_card = arg[3] - local cards = arg[4] - local win_list = arg[5] - local index = self:GetPos(win_seat) - local info = self._player_card_info[index] + local lose_seat = arg[2] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] self:RemoveCursor() info:UpdateHandCard(true, true) @@ -263,74 +256,72 @@ function M:EventInit() if win_seat == lose_seat then url = "ui://Main_PokeMaJiang/eff_zimo" end - + local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - he:Center() - if _room.room_config.people_num==2 then - if win_seat ~= _room.self_player.seat then - he.scaleY = 0.4 - he.scaleX = 0.4 - he.x = he.width * 0.4 * 0.5 * -1 - he.y = he.height * 0.4 * 0.5 * -1 - end - end - - if win_seat == _room.self_player.seat then - printlog("自己位置=====") - he:Center() + he:Center() + if _room.room_config.people_num == 2 then + if win_seat ~= _room.self_player.seat then + he.scaleY = 0.4 + he.scaleX = 0.4 + he.x = he.width * 0.4 * 0.5 * -1 + he.y = he.height * 0.4 * 0.5 * -1 + end + end + + if win_seat == _room.self_player.seat then + printlog("自己位置=====") + he:Center() elseif url == "ui://Main_PokeMaJiang/eff_zimo" then - printlog("自摸地址==========") + printlog("自摸地址==========") he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end - - - - --- - local isZiMo=win_seat==lose_seat - DataManager.CurrenRoom.isZiMoHu=isZiMo - local hu_sound = isZiMo and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) - printlog("声音====>>>",hu_sound) - self:PlaySound("QiZhiBa_MJ",player.self_user.sex, hu_sound) - - local pNode = info._view - local url = "eff_list1" + + + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) + printlog("声音====>>>", hu_sound) + self:PlaySound("QiZhiBa_MJ", player.self_user.sex, hu_sound) + + local pNode = info._view + local url = "eff_list1" local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_QiZhiBa/" .. url) he_list.touchable = false pNode:AddChild(he_list) he_list:Center() - + coroutine.start(function() - for i = 1 ,#win_list do - local tem = win_list[i] - if tem.type>0 and tem.type<32 then - local com_name = "he" .. tem.type - local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_QiZhiBa/" .. com_name) - coroutine.wait(0.3) - end - - end - - coroutine.wait(2) - obj_win_card:Dispose() - he:Dispose() - he_list:Dispose() - self._popEvent = true + for i = 1, #win_list do + local tem = win_list[i] + if tem.type > 0 and tem.type < 32 then + local com_name = "he" .. tem.type + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_QiZhiBa/" .. com_name) + coroutine.wait(0.3) + end + end + + coroutine.wait(2) + obj_win_card:Dispose() + he:Dispose() + he_list:Dispose() + self._popEvent = true end) - end) _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] - -- ViewUtil.PlaySound("ChaoShan_MJ", "extend/majiang/chaoshan/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + -- ViewUtil.PlaySound("ChaoShan_MJ", "extend/majiang/chaoshan/sound/zhuaniao.mp3") + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) @@ -339,7 +330,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -357,11 +348,11 @@ function M:EventInit() self:RemoveCursor() if self._clearingView == nil then self._clearingView = EXClearingView.new(self._root_view) - coroutine.start(function() + coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() self._popEvent = true - end) + end) end if _room.curren_round ~= _room.room_config.round then @@ -379,7 +370,7 @@ function M:EventInit() end info:UpdateScore() info._view:GetChild("zhanji").visible = true - local num = data[i].hp_info.total_hp + local num = data[i].hp_info.total_hp if num > 0 then info._view:GetController("text_color").selectedIndex = 0 info._view:GetChild("text_jifen").text = "+" .. d2ad(num) @@ -397,7 +388,7 @@ function M:EventInit() self._clearingView = nil end) end - self._player_card_info[1]:ShowHuTip() + self._player_card_info[1]:ShowHuTip() end) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) @@ -405,7 +396,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -413,7 +404,7 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() - end) + end) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -421,21 +412,21 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() self:UpdateRound() self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 + self._state.selectedIndex = 1 self:__PiaoNiaoTip() end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 - end + end if seat == _room.self_player.seat then - if self._com_piao and _room.self_player.entrust then + if self._com_piao and _room.self_player.entrust then self._com_piao:Dispose() self._com_piao = nil _room.curren_round = _room.curren_round - 1 @@ -445,64 +436,61 @@ function M:EventInit() end function M:OutCard(card) - local isOut=IsHasDictionary(card,DataManager.CurrenRoom.laiziInfo) - if isOut==false then - printlog("当前出牌为===>>>"..card) + local isOut = IsHasDictionary(card, DataManager.CurrenRoom.laiziInfo) + if isOut == false then + printlog("当前出牌为===>>>" .. card) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card, function() - local info = self._player_card_info[1] - self:RemoveCursor() - info:UpdateHandCard() + local info = self._player_card_info[1] + self:RemoveCursor() + info:UpdateHandCard() - info:UpdateOutCardList(nil, card, self._cursor) - local cardAudio=string.sub(card,2) - self:PlaySound("QiZhiBa_MJ", self._room.self_player.self_user.sex,tostring(cardAudio)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - else - printlog("鬼牌不能出===>>>"..card) + info:UpdateOutCardList(nil, card, self._cursor) + local cardAudio = string.sub(card, 2) + self:PlaySound("QiZhiBa_MJ", self._room.self_player.self_user.sex, tostring(cardAudio)) + self:PlayMJSound("chupai.mp3") + -- self:ShowHuTip() + end) + else + printlog("鬼牌不能出===>>>" .. card) end end function M:__FangziTip(tip, weight) - local _gamectr = self._gamectr - local _chipeng_tip = UIPackage.CreateObject("Main_PokeMaJiang", "Gcm_action_tips") - _chipeng_tip:GetController("hide_bg").selectedIndex = 1 - self._chipeng_tip = _chipeng_tip - local p = self._room.self_player - -- self._player_card_info[self:GetPos(p.seat)] + local _gamectr = self._gamectr + local _chipeng_tip = UIPackage.CreateObject("Main_PokeMaJiang", "Gcm_action_tips") + _chipeng_tip:GetController("hide_bg").selectedIndex = 1 + self._chipeng_tip = _chipeng_tip + local p = self._room.self_player + -- self._player_card_info[self:GetPos(p.seat)] - local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") - _lit_fanzi:RemoveChildrenToPool() - local _tlist = table.keys(tip.tip_map_type) + local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") + _lit_fanzi:RemoveChildrenToPool() + local _tlist = table.keys(tip.tip_map_type) - local tip_hu = false - local count = #_tlist - table.sort(_tlist) - local isHu = false - for k=1,#_tlist do - - - local td = tip.tip_map_type[_tlist[k]][1] + local tip_hu = false + local count = #_tlist + table.sort(_tlist) + local isHu = false + for k = 1, #_tlist do + local td = tip.tip_map_type[_tlist[k]][1] local url = "ui://Main_PokeMaJiang/Btn_fztip" local td_weight = td.weight if td_weight == 16 then td_weight = 8 end if td_weight == 8 then url = "ui://Main_PokeMaJiang/Btn_hu" end local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_PokeMaJiang/fztip_"..td_weight + btn_t.icon = "ui://Main_PokeMaJiang/fztip_" .. td_weight btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - - end + btn_t.onClick:Add(self.__TipAction, self) + end - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_PokeMaJiang/Btn_pass") - _btn_pass.onClick:Set(function() + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_PokeMaJiang/Btn_pass") + _btn_pass.onClick:Set(function() if isHu then local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() + guo_msg.onOk:Add(function() _gamectr:SendAction(0) _chipeng_tip:Dispose() self._chipeng_tip = nil @@ -514,29 +502,26 @@ function M:__FangziTip(tip, weight) _chipeng_tip:Dispose() self._chipeng_tip = nil end - end) + end) - self._view:AddChild(_chipeng_tip) - _chipeng_tip:Center() + self._view:AddChild(_chipeng_tip) + _chipeng_tip:Center() end - - - function M:__TipAction(context) - local data = context.sender.data - local _gamectr = self._gamectr - local tip = data[1] - local td = data[2] - local list = tip.tip_map_type[td.weight] - if (#list > 1) then - self:_ChiView(list, function(id) - _gamectr:SendAction(id) - self:__CloseTip() - end) - self._chipeng_tip.visible = false - return - end + local data = context.sender.data + local _gamectr = self._gamectr + local tip = data[1] + local td = data[2] + local list = tip.tip_map_type[td.weight] + if (#list > 1) then + self:_ChiView(list, function(id) + _gamectr:SendAction(id) + self:__CloseTip() + end) + self._chipeng_tip.visible = false + return + end _gamectr:SendAction(td.id) if (self._chipeng_tip == nil) then return end @@ -544,55 +529,60 @@ function M:__TipAction(context) self._chipeng_tip = nil end - function M:_ChiView(tiplist, callback) - self._chipeng_tip.visible = false - local _pop_tip_choice = UIPackage.CreateObject("Main_PokeMaJiang", "Pop_tip_choice") - local list_choose1 = _pop_tip_choice:GetChild("Lst_choose") - local list_choose2 = _pop_tip_choice:GetChild("Lst_choose2") - local crossCtr = _pop_tip_choice:GetController("state") - crossCtr.selectedIndex = #tiplist == 3 and 0 or (#tiplist == 2 and 1 or (#tiplist == 4 and 2 or (#tiplist == 5 and 3 or 4))) - _pop_tip_choice:GetChild("Btn_cross").onClick:Add(function() - _pop_tip_choice:Dispose() - self._chipeng_tip.visible = true - end) - list_choose1:RemoveChildrenToPool() - list_choose2:RemoveChildrenToPool() - for i = 1, #tiplist do - local list_choose = i <= 3 and list_choose1 or list_choose2 - local item_choose = list_choose:AddItemFromPool() - item_choose:GetController("type").selectedIndex = (1 == tiplist[i].weight or 2 == tiplist[i].weight) and 1 or 0 - if tiplist[i].weight ~= 1 then - for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_PokeMaJiang", self:GetPrefix() .. "201_"..tiplist[i].card) - end - else - local tem = {} - table.insert(tem, tiplist[i].opcard[1]) - table.insert(tem, tiplist[i].opcard[2]) - local tcard = tiplist[i].card - table.insert(tem, tcard) - table.sort(tem, function(a, b) - return a < b - end) - item_choose:GetChild("card1").icon = UIPackage.GetItemURL("Main_PokeMaJiang", self:GetPrefix() .. "201_"..tem[1]) - item_choose:GetChild("card2").icon = UIPackage.GetItemURL("Main_PokeMaJiang", self:GetPrefix() .. "201_"..tem[2]) - item_choose:GetChild("card4").icon = UIPackage.GetItemURL("Main_PokeMaJiang", self:GetPrefix() .. "201_"..tem[3]) - local cardpos = tem[2] > tcard and 1 or (tem[2] < tcard and 4 or 2) - item_choose:GetChild("card" .. cardpos):GetController("color").selectedIndex = 1 - end - item_choose.onClick:Add(function() - callback(tiplist[i].id) - end) - end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) - self._view:AddChild(_pop_tip_choice) - self._pop_tip_choice = _pop_tip_choice + self._chipeng_tip.visible = false + local _pop_tip_choice = UIPackage.CreateObject("Main_PokeMaJiang", "Pop_tip_choice") + local list_choose1 = _pop_tip_choice:GetChild("Lst_choose") + local list_choose2 = _pop_tip_choice:GetChild("Lst_choose2") + local crossCtr = _pop_tip_choice:GetController("state") + crossCtr.selectedIndex = #tiplist == 3 and 0 or + (#tiplist == 2 and 1 or (#tiplist == 4 and 2 or (#tiplist == 5 and 3 or 4))) + _pop_tip_choice:GetChild("Btn_cross").onClick:Add(function() + _pop_tip_choice:Dispose() + self._chipeng_tip.visible = true + end) + list_choose1:RemoveChildrenToPool() + list_choose2:RemoveChildrenToPool() + for i = 1, #tiplist do + local list_choose = i <= 3 and list_choose1 or list_choose2 + local item_choose = list_choose:AddItemFromPool() + item_choose:GetController("type").selectedIndex = (1 == tiplist[i].weight or 2 == tiplist[i].weight) and 1 or 0 + if tiplist[i].weight ~= 1 then + for j = 1, 4 do + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_PokeMaJiang", + self:GetPrefix() .. "201_" .. tiplist[i].card) + end + else + local tem = {} + table.insert(tem, tiplist[i].opcard[1]) + table.insert(tem, tiplist[i].opcard[2]) + local tcard = tiplist[i].card + table.insert(tem, tcard) + table.sort(tem, function(a, b) + return a < b + end) + item_choose:GetChild("card1").icon = UIPackage.GetItemURL("Main_PokeMaJiang", + self:GetPrefix() .. "201_" .. tem[1]) + item_choose:GetChild("card2").icon = UIPackage.GetItemURL("Main_PokeMaJiang", + self:GetPrefix() .. "201_" .. tem[2]) + item_choose:GetChild("card4").icon = UIPackage.GetItemURL("Main_PokeMaJiang", + self:GetPrefix() .. "201_" .. tem[3]) + local cardpos = tem[2] > tcard and 1 or (tem[2] < tcard and 4 or 2) + item_choose:GetChild("card" .. cardpos):GetController("color").selectedIndex = 1 + end + item_choose.onClick:Add(function() + callback(tiplist[i].id) + end) + end + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) + self._view:AddChild(_pop_tip_choice) + self._pop_tip_choice = _pop_tip_choice end function M:OnFangziAction(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -610,36 +600,36 @@ function M:OnFangziAction(...) self:PlaySound("QiZhiBa_MJ", player.self_user.sex,"gang"..math.random(1, 2)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_PokeMaJiang", "杠") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_PokeMaJiang", "杠") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_PokeMaJiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") end--]] - - ---- - local fangzi = "" - local fz_sound = "" - if fz.type == FZType.Peng then - fangzi = "碰" - fz_sound = "peng"..math.random(1, 3) - elseif fz.type == FZType.Chi then - fangzi = "吃" - fz_sound = "chi"..math.random(1, 3) - else - if fz.opengang then - fangzi = "杠" - fz_sound = "gang"..math.random(1, 2) - else - fangzi = "补" - fz_sound = "buzhang" - end - end - self:PlaySound("QiZhiBa_MJ",player.self_user.sex,fz_sound) - effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_PokeMaJiang", fangzi) - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_PokeMaJiang", fangzi) - - - - - + + ---- + local fangzi = "" + local fz_sound = "" + if fz.type == FZType.Peng then + fangzi = "碰" + fz_sound = "peng" .. math.random(1, 3) + elseif fz.type == FZType.Chi then + fangzi = "吃" + fz_sound = "chi" .. math.random(1, 3) + else + if fz.opengang then + fangzi = "杠" + fz_sound = "gang" .. math.random(1, 2) + else + fangzi = "补" + fz_sound = "buzhang" + end + end + self:PlaySound("QiZhiBa_MJ", player.self_user.sex, fz_sound) + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_PokeMaJiang", fangzi) + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_PokeMaJiang", fangzi) + + + + + effect.touchable = false effect:GetTransition("t2"):Play() pNode:AddChild(effect) @@ -662,13 +652,13 @@ end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_QiZhiBa","Panel_Birds") + self._niao_View = UIPackage.CreateObject("Extend_MJ_QiZhiBa", "Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do + for i = 1, #list do --添加背面的麻將 local item = list_niao_card:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_PokeMaJiang", "202_00") @@ -680,7 +670,7 @@ function M:RunNiao(list, start_seat) local card = list[i].card coroutine.wait(0.3) item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_PokeMaJiang", "201_"..card) + item.icon = UIPackage.GetItemURL("Main_PokeMaJiang", "201_" .. card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() @@ -705,17 +695,17 @@ end -- end function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_PokeMaJiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao + local obj_piao = UIPackage.CreateObject("Main_PokeMaJiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end function M:ReloadRoom(bskip) @@ -728,36 +718,36 @@ function M:ReloadRoom(bskip) -- end if bskip == nil or bskip == false then - if not room.playing then - self._state.selectedIndex = 2 - else - self._state.selectedIndex = 1 - self._room._reload_flag = true - end + if not room.playing then + self._state.selectedIndex = 2 + else + self._state.selectedIndex = 1 + self._room._reload_flag = true + end end - + for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end - info:UpdateHandCard() + info:UpdateHandCard() local head_info = self._player_info[self:GetPos(p.seat)] head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true - local num = p.total_hp or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = d2ad(num) - end + local num = p.total_hp or 0 + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = d2ad(num) + end if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() @@ -771,34 +761,34 @@ function M:ReloadRoom(bskip) -- self._player_info[self:GetPos(p.seat)]:Ready(true) -- end if bskip == nil or bskip == false then - if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) - end - end - if p.piao_niao~=nil and p.piao_niao > 0 then + if p.ready and room.playing == false then + self._player_info[self:GetPos(p.seat)]:Ready(true) + end + end + if p.piao_niao ~= nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end -- self:ShowHuTip() - + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() - end + end end function M:PlayerChangeLineState() - -- local isOutCard = true - -- local str = "玩家 " - -- for _ , player in ipairs(self._room.player_list) do - -- if player.line_state == 0 then - -- isOutCard = false - -- end - -- end - -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard + -- local isOutCard = true + -- local str = "玩家 " + -- for _ , player in ipairs(self._room.player_list) do + -- if player.line_state == 0 then + -- isOutCard = false + -- end + -- end + -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard end function M:UpdateCardBox(seat) @@ -832,4 +822,4 @@ function M:Destroy() UIPackage.RemovePackage("extend/majiang/qizhiba/ui/Extend_MJ_QiZhiBa") end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/qizhiba/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/qizhiba/ExtendConfig.lua index c863f1ff..34e54c68 100644 --- a/lua_probject/extend_project/extend/majiang/qizhiba/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/qizhiba/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = import(".main.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,49 +45,49 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - printlog("初始化房间数据====>>>") - pt(_tableInfo) - printlog(_tableInfo.laiziCard) - printlog(_tableInfo.laiziCard2) - printlog(_tableInfo.laiziCard3) - - room.laiziInfo={} - if _tableInfo.laiziCard2>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard) - table.insert(room.laiziInfo,_tableInfo.laiziCard2) - if _tableInfo.laiziCard3>0 then - local str=string.sub(_tableInfo.laiziCard3,2) - for i=1,4 do - table.insert(room.laiziInfo,tonumber(i..str)) - end - end - room.beforelaiziCardId=_tableInfo.laiziCard3 - else - room.laiziInfo=nil - end - --pt(room.laiziInfo) + printlog("初始化房间数据====>>>") + pt(_tableInfo) + printlog(_tableInfo.laiziCard) + printlog(_tableInfo.laiziCard2) + printlog(_tableInfo.laiziCard3) + + room.laiziInfo = {} + if _tableInfo.laiziCard2 > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard) + table.insert(room.laiziInfo, _tableInfo.laiziCard2) + if _tableInfo.laiziCard3 > 0 then + local str = string.sub(_tableInfo.laiziCard3, 2) + for i = 1, 4 do + table.insert(room.laiziInfo, tonumber(i .. str)) + end + end + room.beforelaiziCardId = _tableInfo.laiziCard3 + else + room.laiziInfo = nil + end + --pt(room.laiziInfo) local _config = _tableInfo["config"] - pt(_config) + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -96,10 +96,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort2) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -110,24 +110,24 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - fz.allCard=op["opcard"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + fz.allCard = op["opcard"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -151,7 +151,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -160,21 +160,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort2) @@ -190,4 +190,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/qizhiba/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/qizhiba/MJPlayerSelfCardInfoView.lua index d30ec3f8..28f601ce 100644 --- a/lua_probject/extend_project/extend/majiang/qizhiba/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/qizhiba/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = import(".main.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -15,80 +15,72 @@ function M.new(view,mainView) return self end -function M:ShowHuTip(card_list,currentOnclickCard) - if currentOnclickCard then - if DataManager.CurrenRoom.self_player.CardTingList then - local tempV=DataManager.CurrenRoom.self_player.CardTingList[currentOnclickCard] - if tempV and #tempV>0 then - self._mainView._hu_tip:FillData(tempV) - else - self._mainView._hu_tip:HideHuTipsPanel() - end - end - - else - --[[if DataManager.CurrenRoom.self_player.allTingPaiList and #DataManager.CurrenRoom.self_player.allTingPaiList>0 then +function M:ShowHuTip(card_list, currentOnclickCard) + if currentOnclickCard then + if DataManager.CurrenRoom.self_player.CardTingList then + local tempV = DataManager.CurrenRoom.self_player.CardTingList[currentOnclickCard] + if tempV and #tempV > 0 then + self._mainView._hu_tip:FillData(tempV) + else + self._mainView._hu_tip:HideHuTipsPanel() + end + end + else + --[[if DataManager.CurrenRoom.self_player.allTingPaiList and #DataManager.CurrenRoom.self_player.allTingPaiList>0 then self._mainView._hu_tip:FillData(DataManager.CurrenRoom.self_player.allTingPaiList) end--]] - end - + end end function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then self._out_card = true - if DataManager.CurrenRoom.self_player.tingPaiList and #DataManager.CurrenRoom.self_player.tingPaiList>0 then - for i = 1, #_carViewList do - local btn = _carViewList[i].card - local isTing,curIndex=CheckDictionaryFromContent(_carViewList[i].card_item,DataManager.CurrenRoom.self_player.tingPaiList) - if isTing then - --printlog("听牌提示===》》》",curIndex) - --pt(DataManager.CurrenRoom.self_player.tingPaiList[curIndex]) - local value=#DataManager.CurrenRoom.self_player.tingPaiList[curIndex].value - if tonumber(value)>1 then - btn:GetController("mark_ting").selectedIndex=2 - else - btn:GetController("mark_ting").selectedIndex=1 - end - - end - end - - end - - --DataManager.CurrenRoom.self_player.tingPaiList=nil - + if DataManager.CurrenRoom.self_player.tingPaiList and #DataManager.CurrenRoom.self_player.tingPaiList > 0 then + for i = 1, #_carViewList do + local btn = _carViewList[i].card + local isTing, curIndex = CheckDictionaryFromContent(_carViewList[i].card_item, + DataManager.CurrenRoom.self_player.tingPaiList) + if isTing then + --printlog("听牌提示===》》》",curIndex) + --pt(DataManager.CurrenRoom.self_player.tingPaiList[curIndex]) + local value = #DataManager.CurrenRoom.self_player.tingPaiList[curIndex].value + if tonumber(value) > 1 then + btn:GetController("mark_ting").selectedIndex = 2 + else + btn:GetController("mark_ting").selectedIndex = 1 + end + end + end + end + + --DataManager.CurrenRoom.self_player.tingPaiList=nil else for i = 1, #_carViewList do local btn = _carViewList[i].card @@ -98,36 +90,32 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end - - - function M:__OnClickHandCard(context) local button = context.sender local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end end if self._out_card then - printlog("点击开始出牌===>>>") - self:ShowHuTip(card_list,button.data.card_item) + printlog("点击开始出牌===>>>") + self:ShowHuTip(card_list, button.data.card_item) end -- 标记出牌 @@ -153,19 +141,19 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) - local isOut=IsHasDictionary(card.card_item,DataManager.CurrenRoom.laiziInfo) - if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and isOut==false) then + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + local isOut = IsHasDictionary(card.card_item, DataManager.CurrenRoom.laiziInfo) + if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and isOut == false) then self._mainView:OutCard(card.card_item) button.touchable = false self.outcard_button = button @@ -184,6 +172,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -198,10 +187,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJMainView.lua b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJMainView.lua index 8179223d..913cc0a0 100644 --- a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJMainView.lua +++ b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJMainView.lua @@ -4,15 +4,15 @@ local TableBG = require("Game.Data.TableBG") local MJSettingView = import(".MJSettingViewNew") local MJMainRightPanelView = import(".MJMainRightPanelView") - local bg_config = { - {id = 1, url = "base/main_pokemajiang/bg/bg1", thumb = "ui://Main_PokeMaJiang/b01"}, - {id = 2, url = "base/main_pokemajiang/bg/bg2", thumb = "ui://Main_PokeMaJiang/b02"}, - {id = 3, url = "base/main_pokemajiang/bg/bg3", thumb = "ui://Main_PokeMaJiang/b03"} +local bg_config = { + { id = 1, url = "base/main_pokemajiang/bg/bg1", thumb = "ui://Main_PokeMaJiang/b01" }, + { id = 2, url = "base/main_pokemajiang/bg/bg2", thumb = "ui://Main_PokeMaJiang/b02" }, + { id = 3, url = "base/main_pokemajiang/bg/bg3", thumb = "ui://Main_PokeMaJiang/b03" } } local M = {} -setmetatable(M,{__index = MainView}) +setmetatable(M, { __index = MainView }) local default_bg = 1 function M:InitView(url, use_custom_bg) @@ -28,8 +28,8 @@ function M:InitView(url, use_custom_bg) self._room.card_type = DataManager.CardTypeList[tostring(self._room.game_id)] or 0 UIPackage.AddPackage("base/main_pokemajiang/ui/Main_PokeMaJiang") - - MainView.InitView(self,url) + + MainView.InitView(self, url) local _view = self._view self._cursor = UIPackage.CreateObjectFromURL("ui://Main_PokeMaJiang/Ani_play_bj") if not use_custom_bg then @@ -42,7 +42,7 @@ function M:InitView(url, use_custom_bg) self._ctr_cardbox = _cardbox:GetController("c1") self._tex_leftTime = _cardbox:GetChild("tex_leftnum") - + if self._room.card_type == 2 then self:Change3d(true) @@ -51,42 +51,41 @@ function M:InitView(url, use_custom_bg) end local rightpanel = self._view:GetChild("com_roominfo") - if self._rightPanelView ~= nil then + if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - self._rightPanelView = MJMainRightPanelView.new(self, rightpanel) - - --local tempdsaf=self._view:GetChild("btn_back_jiesan") - --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - - --print("2222222222222222222222") - --print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name) - --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) - --local temp111=self._view:GetChild("btn_back_jiesan").displayObject.gameObject - --temp111:SetActive(false) - self._view:GetChild("btn_back_jiesan").onClick:Set(function () + self._rightPanelView = MJMainRightPanelView.new(self, rightpanel) + + --local tempdsaf=self._view:GetChild("btn_back_jiesan") + --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) + + ---- print("2222222222222222222222") + ---- print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name) + --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) + --local temp111=self._view:GetChild("btn_back_jiesan").displayObject.gameObject + --temp111:SetActive(false) + self._view:GetChild("btn_back_jiesan").onClick:Set(function() if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) self._tex_LeftCard = _view:GetChild("remaining_card") - + self._player_card_info = {} local _player_card_info = self._player_card_info for i = 1, _room.room_config.people_num do local tem = _view:GetChild("player_card_info" .. i) - _player_card_info[i] = self:NewMJPlayerCardInfoView(tem,i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) end local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_card_info[self:GetPos(p.seat)] info:SetPlayer(p) @@ -95,23 +94,22 @@ function M:InitView(url, use_custom_bg) local list = _room.player_list local readyNum = 0 - for i=1,#list do + for i = 1, #list do local p = list[i] if p.ready then readyNum = readyNum + 1 end end - for i=1,#_room.player_list do - + for i = 1, #_room.player_list do local p = _room.player_list[i] - local zi,icon = self:GetPosString(p.seat) + local zi, icon = self:GetPosString(p.seat) if self._room.card_type == 2 then - _cardbox:GetChild("3d_direction"..self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/"..icon + _cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon end - - _cardbox:GetChild("direction"..self:GetIndex(self:GetPos(p.seat))).text = zi + + _cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi end - self._ctr_action = _view:GetController("action") + self._ctr_action = _view:GetController("action") if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then --self._ctr_action.selectedIndex = 2 elseif not _room.self_player.ready then @@ -122,31 +120,28 @@ function M:InitView(url, use_custom_bg) end function M:EventInit() - MainView.EventInit(self) + MainView.EventInit(self) end function M:Change3d(flag) - local _room = self._room local _view = self._view local _cardbox = _view:GetChild("cardbox") - - for i=1,#_room.player_list do - local p = _room.player_list[i] - local zi,icon = self:GetPosString(p.seat) - if self._room.card_type == 2 then - _cardbox:GetChild("3d_direction"..self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/"..icon - end - - _cardbox:GetChild("direction"..self:GetIndex(self:GetPos(p.seat))).text = zi - end - + for i = 1, #_room.player_list do + local p = _room.player_list[i] + local zi, icon = self:GetPosString(p.seat) + if self._room.card_type == 2 then + _cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon + end + + _cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi + end + -- 如果要切换3d牌桌的cardbox位置及上方文字(剩余牌,回合数)显示不错乱,需要做以下改动 -- 取消文字组合的3d控制器的位置, 并设置对cardbox的关联,左左,顶顶 if flag == true then - if _view:GetController("3d") ~= nil then _view:GetController("3d").selectedIndex = 1 _cardbox.x = (_view.width - _cardbox.width) * 0.5 @@ -159,7 +154,7 @@ function M:Change3d(flag) _view:GetController("3d").selectedIndex = 0 _cardbox.x = (_view.width - _cardbox.width) * 0.5 end - + _cardbox:GetController("3d").selectedIndex = 0 _cardbox.x = (_view.width - _cardbox.width) * 0.5 end @@ -174,7 +169,7 @@ end -- self:Change3d(DataManager.CurrenRoom.card_type == 2) -- self:ReloadRoom() - + -- for i = 1, #self._room.player_list do -- local p = self._room.player_list[i] -- local card_info = self._player_card_info[self:GetPos(p.seat)] @@ -199,8 +194,8 @@ function M:NewSettingView() -- gear:Apply() -- settingView.Change3d = function() end - settingView:FillBgSection(function(url,index) - printlog("NewSettingView") + settingView:FillBgSection(function(url, index) + printlog("NewSettingView") LoadGameBg(url, self._root_view) end, self._room.game_id, 1, bg_config) @@ -230,30 +225,29 @@ function M:GetIndex(seat) end function M:GetPosString(seat) - if DataManager.CurrenRoom.room_config.people_num == 4 then if seat == 1 then - return "东","dir_1" + return "东", "dir_1" elseif seat == 2 then - return "南","dir_2" - elseif seat == 3 then - return "西","dir_3" + return "南", "dir_2" + elseif seat == 3 then + return "西", "dir_3" elseif seat == 4 then - return "北","dir_4" + return "北", "dir_4" end elseif DataManager.CurrenRoom.room_config.people_num == 3 then if seat == 1 then - return "东","dir_1" + return "东", "dir_1" elseif seat == 2 then - return "南","dir_2" + return "南", "dir_2" elseif seat == 3 then - return "西","dir_3" + return "西", "dir_3" end elseif DataManager.CurrenRoom.room_config.people_num == 2 then if seat == 1 then - return "东","dir_1" + return "东", "dir_1" elseif seat == 2 then - return "西","dir_3" + return "西", "dir_3" end end end @@ -261,7 +255,7 @@ end function M:SetCardBoxPosition() local _room = self._room for i = 1, _room.room_config.people_num do - local tex = self._view:GetChild("cardbox"):GetChild("direction"..i) + local tex = self._view:GetChild("cardbox"):GetChild("direction" .. i) local index = _room.self_player.seat + i - 1 index = index > 4 and index - 4 or index tex.text = self._gamectr:GetPosString(index) @@ -275,11 +269,11 @@ function M:markOutCards(showTip, data) for j = 1, #p.outcard_list do local card = p.outcard_list[j] if card == data then - for k = 1, #p.outcard_list do + for k = 1, #p.outcard_list do local obj = info:GetOutCardByIndex(k) if obj.data == card then obj:GetController("gray").selectedIndex = showTip and 1 or 0 - end + end end end end @@ -287,20 +281,20 @@ function M:markOutCards(showTip, data) end function M:OnPlayerEnter(...) - MainView.OnPlayerEnter(self,...) - local arg = {...} + MainView.OnPlayerEnter(self, ...) + local arg = { ... } local p = arg[1] local info = self._player_card_info[self:GetPos(p.seat)] info:SetPlayer(p) info:FillData() end -function M:OnPlayerReady( ... ) - local arg = {...} +function M:OnPlayerReady(...) + local arg = { ... } local p = arg[1] local _room = self._room local _view = self._view - + local _player_info = self._player_info if p.seat == _room.self_player.seat then self._ctr_action.selectedIndex = 0 @@ -316,26 +310,25 @@ function M:OnPlayerReady( ... ) if readyNum == _room.room_config.people_num then local _cardbox = _view:GetChild("cardbox") - for i=1,#_room.player_list do - + for i = 1, #_room.player_list do local p = _room.player_list[i] - local zi,icon = self:GetPosString(p.seat) - _cardbox:GetChild("3d_direction"..self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/"..icon - _cardbox:GetChild("direction"..self:GetIndex(self:GetPos(p.seat))).text = zi + local zi, icon = self:GetPosString(p.seat) + _cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon + _cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi end end - + if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then if self._state.selectedIndex == 2 then - local _gamectr = ControllerManager.GetController(GameController) + local _gamectr = ControllerManager.GetController(GameController) _gamectr:StartGame() end - --self._ctr_action.selectedIndex = 2 + --self._ctr_action.selectedIndex = 2 elseif not _room.self_player.ready then - self._ctr_action.selectedIndex = 1 + self._ctr_action.selectedIndex = 1 else - self._ctr_action.selectedIndex = 0 + self._ctr_action.selectedIndex = 0 end end @@ -376,42 +369,42 @@ function M:CountCardLeftNum(card) return count end -function M:OnPlayerLeave( ... ) +function M:OnPlayerLeave(...) MainView.OnPlayerLeave(self, ...) local _room = self._room if _room.banker_seat == _room.self_player.seat then - self._ctr_action.selectedIndex = 0 + self._ctr_action.selectedIndex = 0 end end function M:PlayerChangeLineState() - local isOutCard = true - local str = "玩家 " - for _ , player in ipairs(self._room.player_list) do - if player.line_state == 0 then - isOutCard = false - -- str = str .. self._gamectr:GetPosString(player.seat) .. "、" + local isOutCard = true + local str = "玩家 " + for _, player in ipairs(self._room.player_list) do + if player.line_state == 0 then + isOutCard = false + -- str = str .. self._gamectr:GetPosString(player.seat) .. "、" + end end - end - -- if not isOutCard then - -- str = str.sub(str, 1, string.len(str) - string.len("、")) - -- str = str .. " 正在赶来,请稍等" - -- if self._room.curren_round > 0 then - -- self._waitingView = ModalWaitingView.new(self._view, str) - -- end - -- else - -- if self._waitingView then - -- self._waitingView:CloseWaitingView() - -- end - -- end + -- if not isOutCard then + -- str = str.sub(str, 1, string.len(str) - string.len("、")) + -- str = str .. " 正在赶来,请稍等" + -- if self._room.curren_round > 0 then + -- self._waitingView = ModalWaitingView.new(self._view, str) + -- end + -- else + -- if self._waitingView then + -- self._waitingView:CloseWaitingView() + -- end + -- end self._player_card_info[1]._area_handcard_list.touchable = isOutCard end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) - end - return MJPlayerCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) + end + return MJPlayerCardInfoView.new(view, self) end function M:RemoveCursor() @@ -436,14 +429,14 @@ function M:PlayMJMusic(path) ViewUtil.PlayMuisc(self.asset_group, majiang_asset_path .. path) end -function M:PlaySound(group,sex,path) +function M:PlaySound(group, sex, path) local sex_path = ViewUtil.Sex_Chat[sex] - local path1 = majiang_asset_path .. string.format("%s/%s.mp3",sex_path,path) - ViewUtil.PlaySound(group,path1) + local path1 = majiang_asset_path .. string.format("%s/%s.mp3", sex_path, path) + ViewUtil.PlaySound(group, path1) end function M:GetPrefix() return get_majiang_prefix(DataManager.CurrenRoom.game_id) end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerCardInfoView.lua b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerCardInfoView.lua index 26023ecf..8d8d39ee 100644 --- a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerCardInfoView.lua @@ -20,7 +20,7 @@ local M = PlayerCardInfoView --- Create a new PlayerCardInfoView function M.new(view, mainView) local self = {} - setmetatable(self, {__index = M}) + setmetatable(self, { __index = M }) self._view = view self._mainView = mainView self:init() @@ -101,13 +101,13 @@ function M:GetPrefix() end function M:fillCard(obj, pos_str, card, use3d) - --printlog("=============",card) + --printlog("=============",card) if self._current_card_type == 2 and (use3d == nil or use3d == true) then obj.icon = 'ui://MajiangCard3d/' .. 'b' .. pos_str .. card else obj.icon = 'ui://Main_PokeMaJiang/' .. self:GetPrefix() .. pos_str .. card end - --printlog(obj.icon) + --printlog(obj.icon) end function M:getBackCard(card) @@ -126,10 +126,10 @@ function M:UpdateHandCard(getcard, mp) local handcard_list = self._mask_data['handcard_list'] local oder = handcard_list['oder'] local _player = self._player - -- print(vardump(self._player)) + -- -- print(vardump(self._player)) self._area_handcard_list:RemoveChildren(0, -1, true) - -- print(vardump(_player.card_list)) + -- -- print(vardump(_player.card_list)) if (not mp) then local comp_back = handcard_list['comp_back'] if self._current_card_type == 2 then @@ -161,8 +161,8 @@ function M:UpdateHandCard(getcard, mp) local outcard_list = self._mask_data['outcard_list'] local comp = handcard_list['comp'] local card = outcard_list['card'] - --print("comp"..comp) - -- print(vardump(_player.card_list)) + ---- print("comp"..comp) + -- -- print(vardump(_player.card_list)) if self._current_card_type == 2 then comp = comp .. '_3d' @@ -271,9 +271,9 @@ function M:UpdateOutCardList(outcard, card_item, cursor) sortStart = #outlist sortStep = -1 end - else - sortType = outcard_list['sorting_order3d'] - if sortType == 1 then + else + sortType = outcard_list['sorting_order3d'] + if sortType == 1 then sortStart = 1 sortStep = 1 elseif sortType == -1 then @@ -296,18 +296,18 @@ function M:UpdateOutCardList(outcard, card_item, cursor) end end - ViewUtil.CardPos(obj, self._area_outcard_list, oder, col,0,true) - ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row,0,true) + ViewUtil.CardPos(obj, self._area_outcard_list, oder, col, 0, true) + ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row, 0, true) if self._current_card_type == 2 then self:adjust3dOutPut(obj, self._area_outcard_list, oder, num, i) end - --printlog(cursor) - --printlog("设置出牌======>>>") - --printlog(obj) - --printlog(card) - --printlog(outlist[i + 1]) - + --printlog(cursor) + --printlog("设置出牌======>>>") + --printlog(obj) + --printlog(card) + --printlog(outlist[i + 1]) + self:fillCard(obj, card, outlist[i + 1]) -- 添加角标 self:AddFlag(i + 1, outlist[i], obj) @@ -348,7 +348,7 @@ local function getPos(my_seat, other_seat, total) local pos = 0 pos = other_seat - my_seat + 1 if pos <= 0 then - pos = pos + total + pos = pos + total end if total ~= 4 and pos == total then pos = total + 1 @@ -357,9 +357,9 @@ local function getPos(my_seat, other_seat, total) end function M:UpdateFzList(fz, index, show_card) - printlog("UpdateFzList=====》》》") - printlog("index===",index) - printlog("show_card===",show_card) + printlog("UpdateFzList=====》》》") + printlog("index===", index) + printlog("show_card===", show_card) local gn = 3 if fz.type == FZType.Gang or fz.type == FZType.Gang_An or fz.type == FZType.Gang_Peng then gn = 4 @@ -443,35 +443,35 @@ function M:UpdateFzList(fz, index, show_card) end --if (fz.type == FZType.Gang_An and i == gn) then - -- if self._current_card_type == 2 then - -- _oc.icon = UIPackage.GetItemURL('MajiangCard3d', card3d .. card .. '00') - -- else - -- _oc.icon = UIPackage.GetItemURL(self:GetCardPicPack(), card3d .. card .. '00') - -- end + -- if self._current_card_type == 2 then + -- _oc.icon = UIPackage.GetItemURL('MajiangCard3d', card3d .. card .. '00') + -- else + -- _oc.icon = UIPackage.GetItemURL(self:GetCardPicPack(), card3d .. card .. '00') + -- end - -- if show_card then - -- _oc2.icon = UIPackage.GetItemURL('Main_PokeMaJiang', '202_00') - -- end - -- else - if (fz.type == FZType.Chi) then - local index = i - if oder == AreaOderType.right_left or oder == AreaOderType.down_up then - index = gn - i + 1 - end - - self:fillCard(_oc, card, fz.allCard[index]) - - if show_card then - self:fillCard(_oc2, '201_', fz.allCard[index], false) - end - else - self:fillCard(_oc, card, fz.allCard[i]) - - if show_card then - self:fillCard(_oc2, '201_', fz.card, false) - end + -- if show_card then + -- _oc2.icon = UIPackage.GetItemURL('Main_PokeMaJiang', '202_00') + -- end + -- else + if (fz.type == FZType.Chi) then + local index = i + if oder == AreaOderType.right_left or oder == AreaOderType.down_up then + index = gn - i + 1 end - -- end + + self:fillCard(_oc, card, fz.allCard[index]) + + if show_card then + self:fillCard(_oc2, '201_', fz.allCard[index], false) + end + else + self:fillCard(_oc, card, fz.allCard[i]) + + if show_card then + self:fillCard(_oc2, '201_', fz.card, false) + end + end + -- end end obj.touchable = false @@ -494,7 +494,7 @@ function M:UpdateFzList(fz, index, show_card) -- if num == 0 then return end -- if index == -1 then -- -- local obj = self._area_fz_list:GetChildAt(num - 1) - -- local pic_arrow = UIPackage.CreateObjectFromURL("ui://Main_Majiang/com_arrow") + -- local pic_arrow = UIPackage.CreateObjectFromURL("ui://Main_Majiang/com_arrow") -- obj:AddChild(pic_arrow) -- pic_arrow:Center() -- local my_seat = self._player.seat diff --git a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerSelfCardInfoView.lua index b66999ed..98e09f90 100644 --- a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJPlayerSelfCardInfoView.lua @@ -43,7 +43,7 @@ function M:setHandCardPos(btn_card, i, getcard) end function M:UpdateHandCard(getcard, mp) - print("======================onthisUpdateHandCard") + -- print("======================onthisUpdateHandCard") if self.outcard_button then self.outcard_button:Dispose() self.outcard_button = nil @@ -154,7 +154,7 @@ function M:__OnDragEnd(context) local _room = DataManager.CurrenRoom if not _room or _room:GetReloadStatus() then return end - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then self._mainView:OutCard(card.card_item) button.touchable = false diff --git a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJTableBG.lua b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJTableBG.lua index 95a120fa..2025b708 100644 --- a/lua_probject/extend_project/extend/majiang/qizhiba/main/MJTableBG.lua +++ b/lua_probject/extend_project/extend/majiang/qizhiba/main/MJTableBG.lua @@ -5,12 +5,12 @@ local MJTableBG = {} local M = MJTableBG local mj_bg_config = { - {id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04"}, - {id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05"}, - {id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06"}, - {id = 4, url = "base/main_pokemajiang/bg/bg6", thumb = "ui://Main_PokeMaJiang/b01"}, - {id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02"}, - {id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03"}, + { id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04" }, + { id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05" }, + { id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06" }, + { id = 4, url = "base/main_pokemajiang/bg/bg6", thumb = "ui://Main_PokeMaJiang/b01" }, + { id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02" }, + { id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03" }, } local function GetBG(data, game_id) @@ -39,7 +39,7 @@ local function SetBG(data, game_id, bg_id) if not contain_key then local _data = {} _data.game_id = game_id - _data.bg_id = bg_id + _data.bg_id = bg_id table.insert(data, _data) end end @@ -52,12 +52,12 @@ function MJTableBG.GetTableBG(game_id) local id = -1 local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code) - -- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id) - if json_data ~= nil then - local config_data = json.decode(json_data) - id = GetBG(config_data, game_id) - end - return id + -- -- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id) + if json_data ~= nil then + local config_data = json.decode(json_data) + id = GetBG(config_data, game_id) + end + return id end function MJTableBG.LoadTableBG(id, game_id, main_view) @@ -75,13 +75,13 @@ end function MJTableBG.SaveTableBG(game_id, bg_id) local config_data local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code) - if json_data ~= nil then - config_data = json.decode(json_data) - else - config_data = {} - end + if json_data ~= nil then + config_data = json.decode(json_data) + else + config_data = {} + end SetBG(config_data, game_id, bg_id) Utils.SaveLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code, json.encode(config_data)) end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/tuidaohu/EXMainView.lua b/lua_probject/extend_project/extend/majiang/tuidaohu/EXMainView.lua index 1fd27dbe..d6378fc1 100644 --- a/lua_probject/extend_project/extend/majiang/tuidaohu/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/tuidaohu/EXMainView.lua @@ -10,8 +10,8 @@ local M = {} --- Create a new ZZ_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "MainView" self.asset_group = "TuiDaoHu_MJ" self:init() @@ -25,96 +25,89 @@ function M:InitView(url) self._gps_style = 1 self._full = true UIPackage.AddPackage("extend/majiang/tuidaohu/ui/Extend_MJ_TuiDaoHu") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") self._hu_tip = HuTipView.new(self) - self._view:GetChild('wanfa_text').text =room.room_config.people_num .. '人推倒胡 ' .. room.score_times .. '倍' - - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self:SetReconnentLaiziTips() - - self:PlayerChangeLineState() + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人推倒胡 ' .. room.score_times .. '倍' - if room.playing or room.curren_round > 0 then + self.LaiziBG = self._view:GetChild('n103') + self.LaiziBG.text = "鬼牌" + self.LaiziBG.visible = false + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectlaizi1') + self.Laizi2Btn = self._view:GetChild('selectlaizi2') + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self:SetReconnentLaiziTips() + + self:PlayerChangeLineState() + + if room.playing or room.curren_round > 0 then self:ReloadRoom() end end - - function M:SetReconnentLaiziTips() - local room=DataManager.CurrenRoom - if room.beforelaiziCardId and room.beforelaiziCardId>0 then - self:SetShowLaiZiProcess(room.beforelaiziCardId,room.laiziInfo[1],room.laiziInfo[2],false) - end + local room = DataManager.CurrenRoom + if room.beforelaiziCardId and room.beforelaiziCardId > 0 then + self:SetShowLaiZiProcess(room.beforelaiziCardId, room.laiziInfo[1], room.laiziInfo[2], false) + end end - -function M:SetLaiZiCard(btn,cardId) - btn.icon='ui://Main_Majiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..cardId +function M:SetLaiZiCard(btn, cardId) + btn.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId end - -function M:IsShowLaiZi(btn,isShow) - btn.visible=isShow +function M:IsShowLaiZi(btn, isShow) + btn.visible = isShow end - function M:HideAllLaiZiCard() - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - self.LaiziBG.visible=false + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + self.LaiziBG.visible = false end -function M:SetShowLaiZiProcess(beforeLaiziID,currentLaizi1ID,currentLaizi2ID,isShowAnim) - --zhongid=currentLaizi1ID - if isShowAnim==nil then isShowAnim=false end - - printlog("当前赋值结果为====>>>") - print(beforeLaiziID) - print(currentLaizi1ID) - print(currentLaizi2ID) - self:HideAllLaiZiCard() - self:SetLaiZiCard(self.selectLaiziBtn,beforeLaiziID) - self:SetLaiZiCard(self.Laizi1Btn,currentLaizi1ID) - if currentLaizi2ID then - self:SetLaiZiCard(self.Laizi2Btn,currentLaizi2ID) - end - - - if isShowAnim==true then - self:IsShowLaiZi(self.selectLaiziBtn,true) - coroutine.start( - function() - coroutine.wait(1) - self:HideAllLaiZiCard() - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - - end - ) - else - self.LaiziBG.visible=true - self:IsShowLaiZi(self.Laizi1Btn,true) - if currentLaizi2ID then - self:IsShowLaiZi(self.Laizi2Btn,true) - end - end - self.LaiziBG.visible=true -end +function M:SetShowLaiZiProcess(beforeLaiziID, currentLaizi1ID, currentLaizi2ID, isShowAnim) + --zhongid=currentLaizi1ID + if isShowAnim == nil then isShowAnim = false end + printlog("当前赋值结果为====>>>") + -- print(beforeLaiziID) + -- print(currentLaizi1ID) + -- print(currentLaizi2ID) + self:HideAllLaiZiCard() + self:SetLaiZiCard(self.selectLaiziBtn, beforeLaiziID) + self:SetLaiZiCard(self.Laizi1Btn, currentLaizi1ID) + if currentLaizi2ID then + self:SetLaiZiCard(self.Laizi2Btn, currentLaizi2ID) + end + + + if isShowAnim == true then + self:IsShowLaiZi(self.selectLaiziBtn, true) + coroutine.start( + function() + coroutine.wait(1) + self:HideAllLaiZiCard() + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + ) + else + self.LaiziBG.visible = true + self:IsShowLaiZi(self.Laizi1Btn, true) + if currentLaizi2ID then + self:IsShowLaiZi(self.Laizi2Btn, true) + end + end + self.LaiziBG.visible = true +end function M:UpdateRound() self._view:GetChild("tex_round1").text = self._room.curren_round @@ -122,58 +115,58 @@ function M:UpdateRound() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) end - return MJPlayerCardInfoView.new(view,self) + return MJPlayerCardInfoView.new(view, self) end function M:EventInit() - -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MainView.EventInit(self) + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info - local _gamectr = self._gamectr + local _gamectr = self._gamectr - _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) - local arg = {...} - self:SetShowLaiZiProcess(arg[1],arg[2],arg[3],arg[4]) + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4]) end) - _gamectr:AddEventListener(TX_GameEvent.SendCards,function( ... ) + _gamectr:AddEventListener(TX_GameEvent.SendCards, function(...) -- self:ShowHuTip() self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:UpdateHandCard() end end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = {...} + _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) + local arg = { ... } self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) @@ -187,11 +180,11 @@ function M:EventInit() info:UpdateHandCard(true) end) - local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -208,7 +201,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] -- self._tex_leftTime.text = arg[3] @@ -219,27 +212,27 @@ function M:EventInit() end) _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local weight = arg[2] self:__FangziTip(_tip, weight) end) - _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] - local lose_seat = arg[2] - local win_card = arg[3] - local cards = arg[4] - local win_list = arg[5] - local index = self:GetPos(win_seat) - local info = self._player_card_info[index] + local lose_seat = arg[2] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] self:RemoveCursor() info:UpdateHandCard(true, true) @@ -261,73 +254,72 @@ function M:EventInit() if win_seat == lose_seat then url = "ui://Main_Majiang/eff_zimo" end - + local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - he:Center() - if _room.room_config.people_num==2 then - if win_seat ~= _room.self_player.seat then - he.scaleY = 0.4 - he.scaleX = 0.4 - he.x = he.width * 0.4 * 0.5 * -1 - he.y = he.height * 0.4 * 0.5 * -1 - end - end - - if win_seat == _room.self_player.seat then - printlog("自己位置=====") - he:Center() + he:Center() + if _room.room_config.people_num == 2 then + if win_seat ~= _room.self_player.seat then + he.scaleY = 0.4 + he.scaleX = 0.4 + he.x = he.width * 0.4 * 0.5 * -1 + he.y = he.height * 0.4 * 0.5 * -1 + end + end + + if win_seat == _room.self_player.seat then + printlog("自己位置=====") + he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then - printlog("自摸地址==========") + printlog("自摸地址==========") he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end - - - - --- - local isZiMo=win_seat==lose_seat - DataManager.CurrenRoom.isZiMoHu=isZiMo - local hu_sound = isZiMo and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) - printlog("声音====>>>",hu_sound) - self:PlaySound("TuiDaoHu_MJ",player.self_user.sex, hu_sound) - - local pNode = info._view - local url = "eff_list1" + + + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) + printlog("声音====>>>", hu_sound) + self:PlaySound("TuiDaoHu_MJ", player.self_user.sex, hu_sound) + + local pNode = info._view + local url = "eff_list1" local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_TuiDaoHu/" .. url) he_list.touchable = false pNode:AddChild(he_list) he_list:Center() - + coroutine.start(function() - for i = 1 ,#win_list do - local tem = win_list[i] - if tem.type>0 and tem.type<32 then - local com_name = "he" .. tem.type - local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_TuiDaoHu/" .. com_name) - coroutine.wait(0.3) - end - - end - - coroutine.wait(2) - obj_win_card:Dispose() - he:Dispose() - he_list:Dispose() - self._popEvent = true + for i = 1, #win_list do + local tem = win_list[i] + if tem.type > 0 and tem.type < 32 then + local com_name = "he" .. tem.type + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_TuiDaoHu/" .. com_name) + coroutine.wait(0.3) + end + end + + coroutine.wait(2) + obj_win_card:Dispose() + he:Dispose() + he_list:Dispose() + self._popEvent = true end) end) _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] - -- ViewUtil.PlaySound("TuiDaoHu_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + -- ViewUtil.PlaySound("TuiDaoHu_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) @@ -336,7 +328,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -354,11 +346,11 @@ function M:EventInit() self:RemoveCursor() if self._clearingView == nil then self._clearingView = EXClearingView.new(self._root_view) - coroutine.start(function() + coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() self._popEvent = true - end) + end) end if _room.curren_round ~= _room.room_config.round then @@ -376,7 +368,7 @@ function M:EventInit() end info:UpdateScore() info._view:GetChild("zhanji").visible = true - local num = data[i].hp_info.total_hp + local num = data[i].hp_info.total_hp if num > 0 then info._view:GetController("text_color").selectedIndex = 0 info._view:GetChild("text_jifen").text = "+" .. d2ad(num) @@ -394,7 +386,7 @@ function M:EventInit() self._clearingView = nil end) end - self._player_card_info[1]:ShowHuTip() + self._player_card_info[1]:ShowHuTip() end) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) @@ -402,7 +394,7 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -410,7 +402,7 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() - end) + end) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -418,21 +410,21 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() self:UpdateRound() self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 + self._state.selectedIndex = 1 self:__PiaoNiaoTip() end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 - end + end if seat == _room.self_player.seat then - if self._com_piao and _room.self_player.entrust then + if self._com_piao and _room.self_player.entrust then self._com_piao:Dispose() self._com_piao = nil _room.curren_round = _room.curren_round - 1 @@ -443,21 +435,21 @@ end function M:OutCard(card) if card ~= 0 then - printlog("当前出牌为===>>>"..card) + printlog("当前出牌为===>>>" .. card) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card, function() - local info = self._player_card_info[1] - self:RemoveCursor() - info:UpdateHandCard() + local info = self._player_card_info[1] + self:RemoveCursor() + info:UpdateHandCard() - info:UpdateOutCardList(nil, card, self._cursor) - self:PlaySound("TuiDaoHu_MJ", self._room.self_player.self_user.sex,tostring(card)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - else - printlog("鬼牌不能出===>>>"..card) + info:UpdateOutCardList(nil, card, self._cursor) + self:PlaySound("TuiDaoHu_MJ", self._room.self_player.self_user.sex, tostring(card)) + self:PlayMJSound("chupai.mp3") + -- self:ShowHuTip() + end) + else + printlog("鬼牌不能出===>>>" .. card) end end @@ -475,37 +467,37 @@ function M:__FangziTip(tip, weight) local tip_hu = false local count = #_tlist - for k=1,#_tlist do + for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] local url = "ui://Main_Majiang/Btn_fztip" local td_weight = td.weight if td_weight == 16 then td_weight = 8 end if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end local btn_t = _lit_fanzi:AddItemFromPool(url) - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight + btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) + btn_t.onClick:Add(self.__TipAction, self) end -- if not (tonumber(weight) >= 16) then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else + local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") + -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") + _btn_pass.onClick:Set(function() + if tonumber(weight) >= 8 then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() _gamectr:SendAction(0) _chipeng_tip:Dispose() self._chipeng_tip = nil - end - end) + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end + end) -- end self._view:AddChild(_chipeng_tip) @@ -548,20 +540,21 @@ function M:_ChiView(tiplist, callback) local item_choose = list_choose:AddItemFromPool() item_choose:GetController("type").selectedIndex = 0 for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", "202_"..tiplist[i].card) + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. tiplist[i].card) end item_choose.onClick:Add(function() callback(tiplist[i].id) end) end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end function M:OnFangziAction(...) self:__CloseTip() - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -571,15 +564,15 @@ function M:OnFangziAction(...) local pNode = info._mask_liangpai local effect = UIPackage.CreateObject("Extend_MJ_TuiDaoHu", "FzEffect") if fz.type == FZType.Peng then - self:PlaySound("TuiDaoHu_MJ", player.self_user.sex,"peng"..math.random(1, 3)) + self:PlaySound("TuiDaoHu_MJ", player.self_user.sex, "peng" .. math.random(1, 3)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") else - self:PlaySound("TuiDaoHu_MJ", player.self_user.sex,"gang"..math.random(1, 2)) + self:PlaySound("TuiDaoHu_MJ", player.self_user.sex, "gang" .. math.random(1, 2)) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") end effect.touchable = false effect:GetTransition("t2"):Play() @@ -603,13 +596,13 @@ end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_TuiDaoHu","Panel_Birds") + self._niao_View = UIPackage.CreateObject("Extend_MJ_TuiDaoHu", "Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do + for i = 1, #list do --添加背面的麻將 local item = list_niao_card:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") @@ -621,7 +614,7 @@ function M:RunNiao(list, start_seat) local card = list[i].card coroutine.wait(0.3) item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_Majiang", "201_"..card) + item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() @@ -646,17 +639,17 @@ end -- end function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end function M:ReloadRoom(bskip) @@ -669,36 +662,36 @@ function M:ReloadRoom(bskip) -- end if bskip == nil or bskip == false then - if not room.playing then - self._state.selectedIndex = 2 - else - self._state.selectedIndex = 1 - self._room._reload_flag = true - end + if not room.playing then + self._state.selectedIndex = 2 + else + self._state.selectedIndex = 1 + self._room._reload_flag = true + end end - + for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end - info:UpdateHandCard() + info:UpdateHandCard() local head_info = self._player_info[self:GetPos(p.seat)] head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true - local num = p.total_hp or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = d2ad(num) - end + local num = p.total_hp or 0 + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = d2ad(num) + end if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() @@ -712,34 +705,34 @@ function M:ReloadRoom(bskip) -- self._player_info[self:GetPos(p.seat)]:Ready(true) -- end if bskip == nil or bskip == false then - if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) - end - end - if p.piao_niao~=nil and p.piao_niao > 0 then + if p.ready and room.playing == false then + self._player_info[self:GetPos(p.seat)]:Ready(true) + end + end + if p.piao_niao ~= nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end -- self:ShowHuTip() - + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() - end + end end function M:PlayerChangeLineState() - -- local isOutCard = true - -- local str = "玩家 " - -- for _ , player in ipairs(self._room.player_list) do - -- if player.line_state == 0 then - -- isOutCard = false - -- end - -- end - -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard + -- local isOutCard = true + -- local str = "玩家 " + -- for _ , player in ipairs(self._room.player_list) do + -- if player.line_state == 0 then + -- isOutCard = false + -- end + -- end + -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard end function M:UpdateCardBox(seat) @@ -773,4 +766,4 @@ function M:Destroy() UIPackage.RemovePackage("extend/majiang/tuidaohu/ui/Extend_MJ_TuiDaoHu") end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/tuidaohu/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/tuidaohu/ExtendConfig.lua index 47525ce9..a22788b0 100644 --- a/lua_probject/extend_project/extend/majiang/tuidaohu/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/tuidaohu/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,46 +45,46 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - printlog("初始化房间数据====>>>") - pt(_tableInfo) - printlog(_tableInfo.laiziCard) - printlog(_tableInfo.laiziCard2) - printlog(_tableInfo.laiziCardBefore) - printlog(_tableInfo.laiziCard2Before) - - room.laiziInfo={} - if _tableInfo.laiziCardBefore>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard) - if _tableInfo.laiziCard2>0 then - table.insert(room.laiziInfo,_tableInfo.laiziCard2) - end - room.beforelaiziCardId=_tableInfo.laiziCardBefore - else - room.laiziInfo=nil - end + printlog("初始化房间数据====>>>") + pt(_tableInfo) + printlog(_tableInfo.laiziCard) + printlog(_tableInfo.laiziCard2) + printlog(_tableInfo.laiziCardBefore) + printlog(_tableInfo.laiziCard2Before) + + room.laiziInfo = {} + if _tableInfo.laiziCardBefore > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard) + if _tableInfo.laiziCard2 > 0 then + table.insert(room.laiziInfo, _tableInfo.laiziCard2) + end + room.beforelaiziCardId = _tableInfo.laiziCardBefore + else + room.laiziInfo = nil + end local _config = _tableInfo["config"] - pt(_config) + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -93,10 +93,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -107,23 +107,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -147,7 +147,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -156,21 +156,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -186,4 +186,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/tuidaohu/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/tuidaohu/MJPlayerSelfCardInfoView.lua index 51ef5dd2..ad01283f 100644 --- a/lua_probject/extend_project/extend/majiang/tuidaohu/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/tuidaohu/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -16,16 +16,16 @@ function M.new(view,mainView) end function M:ShowHuTip(card_list) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - for i=1,#DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then - table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] ) - end - end - end - + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end self._mainView._hu_tip:FillData(tingList) end @@ -34,32 +34,28 @@ function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) local _carViewList = self._carViewList - if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then - for i=1,#self._carViewList do - local obj=self._carViewList[i] - if obj and obj.card then - if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=1 - end - - end - else - if obj.card.GetController then - if obj.card:GetController("laizi") then - obj.card:GetController("laizi").selectedIndex=0 - end - end - end - - end - end - - - end - - + if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + for i = 1, #self._carViewList do + local obj = self._carViewList[i] + if obj and obj.card then + if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 1 + end + end + else + if obj.card.GetController then + if obj.card:GetController("laizi") then + obj.card:GetController("laizi").selectedIndex = 0 + end + end + end + end + end + end + + local card_list = DataManager.CurrenRoom.self_player.card_list self:ShowHuTip(card_list) if getcard then @@ -72,7 +68,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -91,7 +88,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -108,7 +105,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -116,17 +112,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -159,17 +155,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -189,6 +185,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -203,10 +200,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/majiang/zhuanzhuan/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/zhuanzhuan/ExtendConfig.lua index fff5651f..196563af 100644 --- a/lua_probject/extend_project/extend/majiang/zhuanzhuan/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/zhuanzhuan/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 22 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 22 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,24 +45,24 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - - local reload = s2croom["reload"] + local room = DataManager.CurrenRoom + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] local _config = _tableInfo["config"] @@ -74,10 +74,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -88,23 +88,23 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then self.GetGameController():PlayerReady() end @@ -128,7 +128,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -137,21 +137,21 @@ function M:FillPlayBackData(pd_data) p.ready = _jp["ready"] == 1 and true or false local pid = _jp["aid"] p.piao_niao = _jp["piao_niao"] - -- print(DataManager.SelfUser.account_id,pid) + -- -- print(DataManager.SelfUser.account_id,pid) -- if (278 == pid) then -- room.self_player = p -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -167,4 +167,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/zhuanzhuan/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/zhuanzhuan/MJPlayerSelfCardInfoView.lua index 086d2f23..2b9caf5b 100644 --- a/lua_probject/extend_project/extend/majiang/zhuanzhuan/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/zhuanzhuan/MJPlayerSelfCardInfoView.lua @@ -3,11 +3,11 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) - setmetatable(M, {__index = MJPlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) + setmetatable(M, { __index = MJPlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -16,7 +16,8 @@ function M.new(view,mainView) end function M:ShowHuTip(card_list) - local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) --if #tingList > 0 then -- table.insert(tingList, 412) --end @@ -38,7 +39,8 @@ function M:UpdateHandCard(getcard, mp) local btn = _carViewList[i].card local card = self:GetCard(btn) list_remove(card_list, card) - local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) if #tingList > 0 then local count = 0 for j = 1, #tingList do @@ -57,7 +59,7 @@ function M:UpdateHandCard(getcard, mp) end) -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do + for i = 1, #lst_mark do local tem = lst_mark[i] if all_same or tem.count < lst_mark[1].count then tem.item:GetController("mark_ting").selectedIndex = 1 @@ -81,17 +83,17 @@ function M:__OnClickHandCard(context) local _carViewList = self._carViewList local refresh = true local card_list = {} - for i=1,#_carViewList do + for i = 1, #_carViewList do local btn = _carViewList[i].card local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then + if btn ~= button and btn.selected == true then if button.data.card_item == card then refresh = false else self._mainView:markOutCards(false, card) end btn.selected = false - end + end if not btn.selected then table.insert(card_list, card) end @@ -124,17 +126,17 @@ function M:__OnDragStart(card) end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + if self.outcard_button then + self.outcard_button:Dispose() + self.outcard_button = nil + end local button = context.sender - + --button:RemoveFromParent() local card = button.data local _room = DataManager.CurrenRoom - - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 412) then self._mainView:OutCard(card.card_item) button.touchable = false @@ -154,6 +156,7 @@ function M:CheckPlayerOnlineState() end return true end + function M:Clear(bskip) --self._ctr_state.selectedIndex = 0 self._area_fz_list.x = self._src_fz_list.x @@ -168,10 +171,10 @@ function M:Clear(bskip) self._mask_liangpai:RemoveChildren(0, -1, true) end - for i=1,#self._carViewList do + for i = 1, #self._carViewList do self._carViewList[i].card:Dispose() end self._carViewList = {} - end -return M \ No newline at end of file + +return M diff --git a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_MainView.lua b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_MainView.lua index 5ef2ec3b..a89b79d9 100644 --- a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_MainView.lua +++ b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_MainView.lua @@ -12,8 +12,8 @@ local PlayerInfoView = import(".EXPlayerInfoView") local TableBG = import('Game.Data.TableBG') local M = {} function M.new() - setmetatable(M, {__index = PKMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKMainView }) + local self = setmetatable({}, { __index = M }) self.class = "ChunTian_MainView" self:init() self._gamectr = ControllerManager.GetController(GameController) @@ -22,19 +22,20 @@ end local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/chuntian/bg/bg1', thumb = 'ui://Extend_Poker_ChunTian/table_bg1'}, - {id = 2, url = 'extend/poker/chuntian/bg/bg2', thumb = 'ui://Extend_Poker_ChunTian/table_bg2'}, - {id = 3, url = 'extend/poker/chuntian/bg/bg3', thumb = 'ui://Extend_Poker_ChunTian/table_bg3'} + { id = 1, url = 'extend/poker/chuntian/bg/bg1', thumb = 'ui://Extend_Poker_ChunTian/table_bg1' }, + { id = 2, url = 'extend/poker/chuntian/bg/bg2', thumb = 'ui://Extend_Poker_ChunTian/table_bg2' }, + { id = 3, url = 'extend/poker/chuntian/bg/bg3', thumb = 'ui://Extend_Poker_ChunTian/table_bg3' } } function M:InitView(url) local room = self._room UIPackage.AddPackage("extend/poker/chuntian/ui/Extend_Poker_ChunTian") printlog(room.room_config.people_num) - PKMainView.InitView(self, "ui://Extend_Poker_ChunTian/ChunTian_Main_" .. room.room_config.people_num,nil,1,default_bg,bg_config,nil,"ui://Extend_Poker_ChunTian/SettingWindow1") + PKMainView.InitView(self, "ui://Extend_Poker_ChunTian/ChunTian_Main_" .. room.room_config.people_num, nil, 1, + default_bg, bg_config, nil, "ui://Extend_Poker_ChunTian/SettingWindow1") local _room = DataManager.CurrenRoom local user_id = DataManager.SelfUser.account_id - local json_data = Utils.LoadLocalFile(user_id.._room.game_id.."pai") + local json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "pai") if json_data == nil then local _gamectr = self._gamectr self._room.pai = 0 @@ -44,7 +45,7 @@ function M:InitView(url) self._room.pai = pai end - json_data = Utils.LoadLocalFile(user_id.._room.game_id.."cardsize") + json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "cardsize") if json_data == nil then local _gamectr = self._gamectr self._room.cardsize = 1 @@ -63,7 +64,7 @@ function M:InitView(url) tem.visible = false end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -75,11 +76,10 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = ChunTian_RightPanelView.new(self, rightpanel) - for i=1,#self._room.player_list do - - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + + self._rightPanelView = ChunTian_RightPanelView.new(self, rightpanel) + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -88,30 +88,30 @@ function M:InitView(url) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end - - if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then + + if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then -- body - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text=self._room.score_times .."倍" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = self._room.score_times .. "倍" else - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text="" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = "" end - + self.ctr_state = self._view:GetController("state") self._ctr_action = self._view:GetController("action") self._tex_leftTime = self._view:GetChild("time"):GetChild("title") @@ -119,27 +119,26 @@ function M:InitView(url) self._text_round = self._view:GetChild("round") self.ctr_card_eff = self._view:GetController("card_eff") self._player_card_info = {} - + local _player_card_info = self._player_card_info for i = 1, room.room_config.people_num do local tem = self._view:GetChild("player_card_info_" .. i) _player_card_info[i] = self:NewPlayerCardInfoView(tem, i) end - + local list = room.player_list if not room.self_player.ready then - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else self._ctr_action.selectedIndex = 0 end @@ -153,56 +152,52 @@ function M:InitView(url) self:ReConnectForStart() end else - self._state.selectedIndex = StateType.Palying self:ReconnectForClearing() - end - - self._view:GetChild("btn_back_jiesan").onClick:Set(function () + + self._view:GetChild("btn_back_jiesan").onClick:Set(function() if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) - --local tempdsaf=self._view:GetChild("btn_back_jiesan") - --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) - + --local tempdsaf=self._view:GetChild("btn_back_jiesan") + --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) + --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) + self:ChangeBgmMusic() self:EventInit() - + self._view:GetChild("mask").onClick:Set(function() self:ResetPoker() end) local btn_rule = self._view:GetChild("right_panel"):GetChild("btn_log") self._view:GetChild('info_text'):GetChild('text').text = room.room_config:GetDes() - + if room.room_config.people_num == 2 then - self._view:GetChild('wanfa_text').text = '二人春天' .. room.score_times .. '倍' + self._view:GetChild('wanfa_text').text = '二人春天' .. room.score_times .. '倍' else - if room.room_config.people_num==3 then - self._view:GetChild('wanfa_text').text = '三人春天' .. room.score_times .. '倍' + if room.room_config.people_num == 3 then + self._view:GetChild('wanfa_text').text = '三人春天' .. room.score_times .. '倍' else - self._view:GetChild('wanfa_text').text = '四人春天' .. room.score_times .. '倍' + self._view:GetChild('wanfa_text').text = '四人春天' .. room.score_times .. '倍' end - end - end -function M:UpdateCard( index ) - self._room.pai=index + +function M:UpdateCard(index) + self._room.pai = index local card_info = self._player_card_info[1] -- for i=1,#self._room.player_list do - -- print(i) + -- -- print(i) -- end card_info:updatePoker() for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + if self._room.curren_turn_seat ~= player.seat then if player.out_card_list[1] == 0 then player_card_info:SetOutCardInfo(nil, true) @@ -211,11 +206,11 @@ function M:UpdateCard( index ) end end end - if self.caozuo==1 then + if self.caozuo == 1 then local ctr_number = self.pass == nil and 2 or 1 local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) local cardType, cardNum, cardLength = self._gamectr:GetCardListInfo(lastCardList) - printlog("caozuo",cardType) + printlog("caozuo", cardType) local m = false local next_seat = self._room.self_player.seat + 1 if next_seat > self._room.room_config.people_num then @@ -225,12 +220,12 @@ function M:UpdateCard( index ) m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength,m) + self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength, m) end end function M:UpdateCardSize(index) - self._room.cardsize=index + self._room.cardsize = index local card_info = self._player_card_info[1] card_info:updatePoker() end @@ -244,7 +239,7 @@ end function M:OnPlayerEnter(...) MainView.OnPlayerEnter(self, ...) - local arg = {...} + local arg = { ... } local p = arg[1] local index = self:GetPos(p.seat) local info = self._player_info[index] @@ -259,7 +254,7 @@ function M:OnPlayerEnter(...) end function M:OnPlayerReady(...) - local arg = {...} + local arg = { ... } local p = arg[1] local _room = self._room local _player_info = self._player_info @@ -275,89 +270,82 @@ function M:OnPlayerLeave(...) local _room = self._room if not _room.self_player.ready then --self._ctr_action.selectedIndex = 1 - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else self._ctr_action.selectedIndex = 0 end end - function M:EventInit() local _gamectr = ControllerManager.GetController(GameController) MainView.EventInit(self) local _player_info = self._player_info local _player_card_info = self._player_card_info local _room = self._room - - _gamectr:AddEventListener(ChunTian_GameEvent.EventXiPai,function( ... ) - - if self.result_view ~= nil then + + _gamectr:AddEventListener(ChunTian_GameEvent.EventXiPai, function(...) + if self.result_view ~= nil then self.result_view:Destroy() self.result_view = nil end - - self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + self._player_card_info[1]:HidePiao() + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then self.rank_view:Dispose() self.rank_view = nil end - - local list = _room.player_list + + local list = _room.player_list for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - - end - - - --[[if ( currentPlayer ) then + end + + + --[[if ( currentPlayer ) then self._popEvent = false local xipaiCB=function () self._popEvent = true @@ -374,42 +362,37 @@ function M:EventInit() end--]] - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] - self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - - end - - - if ( currentPlayer2 ) then - --self._popEvent = false - local xipaiCB2=function () - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end - - - - end) - + local arg = { ... } + local currentPlayer1 = arg[1] + local currentPlayer2 = arg[2] + self._popEvent = false + if (currentPlayer1) then + local xipaiCB = function() + self._popEvent = true + end + self:PlayXiPai(xipaiCB) + end + + + if (currentPlayer2) then + --self._popEvent = false + local xipaiCB2 = function() + self._popEvent = true + end + self:PlayXiPai1(xipaiCB2) + end + end) + _gamectr:AddEventListener(ChunTian_GameEvent.OnMingCard, function(...) - local arg = {...} + local arg = { ... } local card = arg[1] self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 1 self:PlayCardEff(card) end) - + _gamectr:AddEventListener(ChunTian_GameEvent.OnInitCard, function(...) - local arg = {...} + local arg = { ... } local round = arg[1] local cardlist = arg[2] @@ -418,20 +401,20 @@ function M:EventInit() self.result_view:Destroy() self.result_view = nil end - + self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -444,44 +427,40 @@ function M:EventInit() for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - + if p.seat == self._room.self_player.seat then - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body - card_info:InitPoker(cardlist,true,1) + card_info:InitPoker(cardlist, true, 1) else - card_info:InitPoker(cardlist,true) + card_info:InitPoker(cardlist, true) end - else --card_info:UpdateHandPoker(#cardlist,true,false) --todo --card_info:UpdateRemainCard(#cardlist,true) end end end) - - + + -- _gamectr:AddEventListener(ChunTian_GameEvent.Oener,function ( ... ) -- local arg = {...} -- local seat = arg[1] @@ -489,11 +468,11 @@ function M:EventInit() -- head_info._view:GetController("Oener").selectedIndex=1 -- end) _gamectr:AddEventListener(ChunTian_GameEvent.OnIndexMove, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local isNewBout = arg[2] local index = self:GetPos(seat) - + self.ctr_time.selectedIndex = index -- for i=1,#self._player_info do -- if index==i then @@ -505,16 +484,16 @@ function M:EventInit() -- head_info:MarkBank(false) -- end -- end - + if index == 1 then local card_info = self._player_card_info[index] card_info:SetOutCardInfo(nil, false) - -- if self.MypokerList ~= nil then - -- -- body - -- card_info:Clear() - -- card_info:InitPoker(self.MypokerList, false) - -- self.MypokerList = nil - -- end + -- if self.MypokerList ~= nil then + -- -- body + -- card_info:Clear() + -- card_info:InitPoker(self.MypokerList, false) + -- self.MypokerList = nil + -- end end self._left_time = 20 if self._room.ming_card ~= nil then @@ -526,9 +505,9 @@ function M:EventInit() end end end) - + _gamectr:AddEventListener(ChunTian_GameEvent.OnBombScore, function(...) - local arg = {...} + local arg = { ... } local scoreList = arg[1] -- for i = 1, #scoreList do -- local player = self._room:GetPlayerBySeat(i) @@ -538,9 +517,9 @@ function M:EventInit() -- head_info:UpdateScore(player.total_score) -- end end) - + _gamectr:AddEventListener(ChunTian_GameEvent.OnPlaySucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] local card_number = arg[2] local cardstype = arg[3] @@ -548,21 +527,19 @@ function M:EventInit() local otherList = arg[5] local length = arg[6] self.ctr_time.selectedIndex = 0 - + local index = self:GetPos(p.seat) - if index==1 then - self.caozuo=0 + if index == 1 then + self.caozuo = 0 end local head_info = self._player_info[index] - if head_info._view:GetChild("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil then -- body -- body - if card_number~=nil then + if card_number ~= nil then -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..card_number.."张" + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. card_number .. "张" end - - end local card_info = self._player_card_info[index] card_info:SetOutCardInfo(p.out_card_list, false, true) @@ -576,7 +553,7 @@ function M:EventInit() card_info:DeleteHandCards(p.out_card_list) else card_info:SetRemainCardNumber(card_number == 1) - --card_info:UpdateHandPoker(card_number,false,false) -- todo + --card_info:UpdateHandPoker(card_number,false,false) -- todo end if self._room.is_new_bout == true then for i = 1, #self._room.player_list do @@ -589,13 +566,13 @@ function M:EventInit() -- card_info:PlayCardTypeEff(cardstype) -- if cardstype~=12 then -- -- body - - + + -- if cardstype==10 and length>=6 then -- -- card_info_i -- local chuan = UIPackage.CreateObject("Extend_Poker_ChunTian", "chuan1") -- local card_info_i = self._player_card_info[self:GetPos(p.seat)] - + -- card_info_i._mask_liangpai:AddChild(chuan) -- chuan:GetChild("n0").asMovieClip.playing = true -- ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/sunzi.mp3") @@ -605,7 +582,7 @@ function M:EventInit() -- -- body -- chuan:Dispose() -- end - + -- end) -- else @@ -613,9 +590,8 @@ function M:EventInit() -- end -- end self:_Effect(cardstype, p) - else - if cardstype == 11 and cardstype~=12 then + if cardstype == 11 and cardstype ~= 12 then self:_Effect(cardstype, p) end end @@ -632,41 +608,39 @@ function M:EventInit() self:PlaySound(p.self_user.sex, "card_1") end) end - end) - - - _gamectr:AddEventListener(ChunTian_GameEvent.OnPassSuccCheckCard, function(...) - self._popEvent = false - local arg = {...} - local seat = arg[1] + + + _gamectr:AddEventListener(ChunTian_GameEvent.OnPassSuccCheckCard, function(...) + self._popEvent = false + local arg = { ... } + local seat = arg[1] local cards = arg[2] --self.MypokerList=cards self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(seat)] - if seat == self._room.self_player.seat then - card_info:ClearCheck() - card_info:InitPoker(cards, false) - - --local player=self._room:GetPlayerBySeat(seat) - --if player.out_card_list[1] == 0 then + if seat == self._room.self_player.seat then + card_info:ClearCheck() + card_info:InitPoker(cards, false) + + --local player=self._room:GetPlayerBySeat(seat) + --if player.out_card_list[1] == 0 then -- player_card_info:SetOutCardInfo(nil, true) --else - --player:SetOutCardInfo({207}, false) - -- end - end - + --player:SetOutCardInfo({207}, false) + -- end + end + self._popEvent = true - end) - + _gamectr:AddEventListener(ChunTian_GameEvent.OnPassSucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] - + self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(p.seat)] - + --card_info:SetOutCardInfo(nil, false) if p.seat == self._room.self_player.seat and self.MypokerList ~= nil then -- body @@ -677,31 +651,30 @@ function M:EventInit() card_info:SetOutCardInfo(nil, true) self:PlaySound(p.self_user.sex, "pass_" .. math.random(1, 4)) end) - + _gamectr:AddEventListener(ChunTian_GameEvent.OnErrorTip, function(...) - local arg = {...} + local arg = { ... } local error_str = arg[1] self._player_card_info[1]:ErrorTip(error_str) -- self._player_card_info[1]:ResetPoker() end) - + _gamectr:AddEventListener(ChunTian_GameEvent.OnPiaoTips, function(...) - local arg = {...} + local arg = { ... } local piao = arg[1] local reload = arg[2] if reload == 0 then - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -723,12 +696,12 @@ function M:EventInit() head_info:UpdatePiao(-1) end end - + self._player_card_info[1]:ShowPiao(piao) end) _gamectr:AddEventListener(ChunTian_GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] @@ -736,20 +709,20 @@ function M:EventInit() end) _gamectr:AddEventListener(ChunTian_GameEvent.OnOptions, function(...) - local arg = {...} + local arg = { ... } local play = arg[1] local pass = arg[5] local card_type = arg[2] local card_number = arg[3] local card_length = arg[4] local ctr_number = pass == nil and 2 or 1 - self.caozuo=1 --记录是否是自己出牌的阶段 - self.pass=pass + self.caozuo = 1 --记录是否是自己出牌的阶段 + self.pass = pass local m = false local next_seat = self._room.self_player.seat + 1 local card_info = self._player_card_info[1] --card_info:SetOutCardInfo(nil, false) - + if self.MypokerList ~= nil then -- body card_info:Clear() @@ -763,19 +736,19 @@ function M:EventInit() m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length,m,play,zdts) + self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) end) - -- 托管 - _gamectr:AddEventListener(ChunTian_GameEvent.Game_TuoGuan, function(...) - local arg = {...} + -- 托管 + _gamectr:AddEventListener(ChunTian_GameEvent.Game_TuoGuan, function(...) + local arg = { ... } local tuoguan = arg[1] local seat = arg[2] - + local tuoguanzhong = self._view:GetChild("tuoguanzhong") local zhezhao = self._view:GetChild("n109") local head_info = self._player_info[self:GetPos(seat)] if (tuoguan == 1) then - if (seat == self._room.self_player.seat ) then + if (seat == self._room.self_player.seat) then tuoguanzhong.visible = true -- tuoguanzhong.sortingOrder = 2 zhezhao.visible = true @@ -785,10 +758,10 @@ function M:EventInit() else head_info._view:GetController("tuoguan").selectedIndex = 1 end - -- if self.ispanguangzhe == true then - -- -- body - -- zhezhao.visible = false - -- end + -- if self.ispanguangzhe == true then + -- -- body + -- zhezhao.visible = false + -- end else if (seat == self._room.self_player.seat) then tuoguanzhong.visible = false @@ -804,7 +777,7 @@ function M:EventInit() end end) _gamectr:AddEventListener(ChunTian_GameEvent.OnResult, function(...) - local arg = {...} + local arg = { ... } local over = arg[1] local info = arg[2] local win_seat = arg[3] @@ -812,9 +785,9 @@ function M:EventInit() local remaincards = arg[5] -- local energyTab = arg[5] printlog("OnResult...") - + local otherpoker_list = self._view:GetChild("otherpoker_list") - + if self.MypokerList ~= nil then -- body local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)] @@ -825,12 +798,12 @@ function M:EventInit() if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end - - if remaincards then + + if remaincards then -- body - local newremaincards = _gamectr:ChangeCodeByFrom(remaincards,true) + local newremaincards = _gamectr:ChangeCodeByFrom(remaincards, true) table.sort(remaincards) for i = #newremaincards, 1, -1 do coroutine.start(function() @@ -840,27 +813,25 @@ function M:EventInit() local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_ChunTian", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj = nil - if DataManager.CurrenRoom.pai==0 then - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if DataManager.CurrenRoom.pai == 0 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card_n .. "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/"..card_n) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card_n) end - else - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/"..card_n.."_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card_n .. "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - end if card_code_obj ~= nil then card_code_obj:SetScale(0.6, 0.6) @@ -868,48 +839,43 @@ function M:EventInit() poker_item:AddChild(card_code_obj) otherpoker_list:AddChild(poker_item) end - end - end) - - end - end - + if self._cor_sound ~= nil then coroutine.stop(self._cor_sound) self._cor_sound = nil end - - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) + + if self.destory_win ~= nil then + coroutine.stop(self.destory_win) end - + self.destory_win = nil self.destory_win = coroutine.start(function() - if chuntianstatus == 1 then - printlog("OnResult...des666") - local url = "ui://Extend_Poker_ChunTian/Spring" - self.WinItem_view = UIPackage.CreateObjectFromURL(url) - self._view:AddChild(self.WinItem_view) - self.WinItem_view:Center() - self.WinItem_view:GetTransition("t0"):Play() - ViewUtil.PlaySound("ChunTian_PK", "base/common/sound/win new.mp3") - coroutine.wait(1.5) - end + if chuntianstatus == 1 then + printlog("OnResult...des666") + local url = "ui://Extend_Poker_ChunTian/Spring" + self.WinItem_view = UIPackage.CreateObjectFromURL(url) + self._view:AddChild(self.WinItem_view) + self.WinItem_view:Center() + self.WinItem_view:GetTransition("t0"):Play() + ViewUtil.PlaySound("ChunTian_PK", "base/common/sound/win new.mp3") + coroutine.wait(1.5) + end if chuntianstatus == 2 then printlog("OnResult...des777") - local url = "ui://Extend_Poker_ChunTian/Spring1" - self.WinItem_view = UIPackage.CreateObjectFromURL(url) - self._view:AddChild(self.WinItem_view) - self.WinItem_view:Center() - self.WinItem_view:GetTransition("t0"):Play() - ViewUtil.PlaySound("ChunTian_PK", "base/common/sound/win new.mp3") - coroutine.wait(1.5) - end + local url = "ui://Extend_Poker_ChunTian/Spring1" + self.WinItem_view = UIPackage.CreateObjectFromURL(url) + self._view:AddChild(self.WinItem_view) + self.WinItem_view:Center() + self.WinItem_view:GetTransition("t0"):Play() + ViewUtil.PlaySound("ChunTian_PK", "base/common/sound/win new.mp3") + coroutine.wait(1.5) + end if chuntianstatus == 3 then local url = "ui://Extend_Poker_ChunTian/Spring3" self.WinItem_view = UIPackage.CreateObjectFromURL(url) @@ -919,9 +885,9 @@ function M:EventInit() ViewUtil.PlaySound("ChunTian_PK", "base/common/sound/win new.mp3") coroutine.wait(1.5) end - - - + + + printlog("OnResult...eff") for i = 1, #info do local player = info[i] @@ -947,13 +913,13 @@ function M:EventInit() rt = self._room.score_times end if over == 1 and self._room.hpOnOff == 1 then - head_info:UpdateScore(player.score / 10) --不可负分 + head_info:UpdateScore(player.score / 10) --不可负分 else head_info:UpdateScore(player.score * rt) end card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) end - + if player.seat ~= self._room.self_player.seat then card_info:UpdateHandPoker(player.cards, false, true) @@ -962,8 +928,9 @@ function M:EventInit() end self:ChangeBgmMusic(1) - - self.result_view = ChunTian_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, remaincards) + + self.result_view = ChunTian_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, + remaincards) self.result_view:Show() if self.WinItem_view ~= nil then self.WinItem_view:Dispose() @@ -975,39 +942,35 @@ function M:EventInit() end if self._room.self_player.entrust == true then - local btn_confirm = self.result_view._view:GetChild("btn_confirm") + local btn_confirm = self.result_view._view:GetChild("btn_confirm") btn_confirm.onClick:Call() end end) - - if over==1 then + + if over == 1 then -- body self:UnmarkSelfTuoguan() ControllerManager.ChangeController(LoddyController) - end - - - end) - + _gamectr:AddEventListener(ChunTian_GameEvent.OnResultByDissolve, function(...) - - local arg = {...} - local over = arg[1] - local info = arg[2] - local winseat = arg[3] - local dissolve = arg[4] + local arg = { ... } + local over = arg[1] + local info = arg[2] + local winseat = arg[3] + local dissolve = arg[4] - self.result_view = ChunTian_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve,nil) - self.result_view:Show() - ControllerManager.ChangeController(LoddyController) - self:UnmarkSelfTuoguan() + self.result_view = ChunTian_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, + nil) + self.result_view:Show() + ControllerManager.ChangeController(LoddyController) + self:UnmarkSelfTuoguan() end) - + -- 确定开始下一局 成功 _gamectr:AddEventListener(ChunTian_GameEvent.OnConfrimToNextGameSucc, function(...) - local arg = {...} + local arg = { ... } local aid = arg[1] local p = self._room:GetPlayerById(aid) if p.seat == self._room.self_player.seat then @@ -1026,10 +989,10 @@ function M:EventInit() local otherpoker_list = self._view:GetChild("otherpoker_list") if otherpoker_list ~= nil then -- body - otherpoker_list.visible=false + otherpoker_list.visible = false otherpoker_list:RemoveChildrenToPool() end - --player_head._view:GetController("Oener").selectedIndex=0 + --player_head._view:GetController("Oener").selectedIndex=0 end end local player_info = self._player_info[self:GetPos(p.seat)] @@ -1038,28 +1001,26 @@ function M:EventInit() -------------------报春提示---------------------------- _gamectr:AddEventListener(ChunTian_GameEvent.OnAlertBaoChun, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] printlog("报春自己座位号+++++++++++++++++") self._player_card_info[1]:ShowBaoChun(1) end) _gamectr:AddEventListener(ChunTian_GameEvent.OnAlertTongYiBaoChun, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] printlog("同意报春座位号+++++++++++++++++") self._player_card_info[1]:ShowTongYiBaoChun(2) end) - end function M:ReConnectForStart() - local _gamectr = ControllerManager.GetController(GameController) self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat) self._state.selectedIndex = 1 self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat) - + self:UpdateRound(self._room.curren_round) for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] @@ -1085,40 +1046,33 @@ function M:ReConnectForStart() end head_info:UpdateScore(player.total_score * rt) end - + head_info:UpdateLineState(player.line_state) head_info:UpdatePiao(player.piao) - - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - - if self._room.room_config.showlength==1 then + + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" end if player.seat == self._room.self_player.seat then - if player.open ~= nil and player.open == 0 and self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if player.open ~= nil and player.open == 0 and self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = player.hand_list player_card_info:InitPoker(player.hand_list, false, 1) - else - player_card_info:InitPoker(player.hand_list, false) end - else - player_card_info:SetRemainCardNumber(player.hand_count == 1) if player.hand_count == 1 then self.bgm_index = 2 @@ -1144,7 +1098,7 @@ function M:ReconnectForClearing() for _, player in ipairs(self._room.player_list) do local head_info = self._player_info[self:GetPos(player.seat)] local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + --如果是体力值不可负分模式 则显示当前的hp值 if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) @@ -1170,93 +1124,88 @@ function M:ReconnectForClearing() head_info:UpdateLineState(player.line_state) --head_info._view:GetController("Oener").selectedIndex=0 head_info:UpdatePiao(player.piao) - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then - -- body - head_info._view:GetController("shengyu").selectedIndex=1 - else - head_info._view:GetController("shengyu").selectedIndex=0 - end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - end - - - if player.seat == self._room.self_player.seat then + if self._room.room_config.showlength == 1 then + -- body + head_info._view:GetController("shengyu").selectedIndex = 1 + else + head_info._view:GetController("shengyu").selectedIndex = 0 + end + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" + end + + + if player.seat == self._room.self_player.seat then player_card_info:InitPoker(player.hand_list, false) else player_card_info:UpdateHandPoker(player.hand_list, false, true) end if player.out_card_list[1] == 0 then - player_card_info:SetOutCardInfo(nil, false) else player_card_info:SetOutCardInfo(player.out_card_list, false) end end - win_seat=self._room.winseat + win_seat = self._room.winseat self._room.winseat = nil - + local remaincards = self._room.remaincards - if self._room.game_status==1 then - - + if self._room.game_status == 1 then -- body coroutine.start(function() coroutine.wait(0.3) - - self.result_view = ChunTian_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat,0,remaincards) - self.result_view:Show() - local card_info = self._player_card_info[1] - card_info._view:GetChild("out_card_list").visible=true - end) - if remaincards then - local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards,true) - + self.result_view = ChunTian_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, + win_seat, 0, remaincards) + self.result_view:Show() + local card_info = self._player_card_info[1] + card_info._view:GetChild("out_card_list").visible = true + end) + if remaincards then + local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards, true) + -- body local otherpoker_list = self._view:GetChild("otherpoker_list") - + if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end for i = #newremaincards, 1, -1 do coroutine.start(function() coroutine.wait(0.1 * (15 - i)) - + local flow = newremaincards[i] % 10 local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_ChunTian", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/"..card_n) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card_n) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card_n .. "_1") end card_code_obj:SetScale(0.6, 0.6) poker_item:AddChild(card_code_obj) otherpoker_list:AddChild(poker_item) end) end - end + end end end @@ -1267,13 +1216,13 @@ function M:CreateRankEff() self.rank_view:GetTransition("t0"):Play() end -function M:_Effect( type1 ,player) +function M:_Effect(type1, player) -- body - - if type1 > 11 or type1 < 3 then - return + + if type1 > 11 or type1 < 3 then + return end - printlog("effect ",type1) + printlog("effect ", type1) local eff_code = 0 if type1 == 3 then eff_code = 2 @@ -1282,7 +1231,7 @@ function M:_Effect( type1 ,player) elseif type1 == 5 then eff_code = 5 elseif type1 == 6 then - eff_code=1 + eff_code = 1 elseif type1 == 7 then return elseif type1 == 8 then @@ -1298,35 +1247,35 @@ function M:_Effect( type1 ,player) end local info = self._player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai - local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/eff_"..eff_code) + local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/eff_" .. eff_code) effect.touchable = false effect:GetTransition("t0"):Play() -- effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - if eff_code==3 then + if eff_code == 3 then self._view:AddChild(effect) else pNode:AddChild(effect) end - - if eff_code==1 then + + if eff_code == 1 then self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/eff_feiji") self._view:AddChild(self.eff_feiji) self.eff_feiji:Center() self.eff_feiji:GetTransition("t0"):Play() end - if eff_code==3 then + if eff_code == 3 then effect:Center() else - if self:GetPos(player.seat)== 1 then - effect.x,effect.y = 0,24 + if self:GetPos(player.seat) == 1 then + effect.x, effect.y = 0, 24 else - effect.x,effect.y = 24,67 + effect.x, effect.y = 24, 67 end end - - + + -- effect:Center() -- if eff_code ==3 then -- coroutine.start(function() @@ -1336,7 +1285,7 @@ function M:_Effect( type1 ,player) -- else coroutine.start(function() coroutine.wait(1) - if self.eff_feiji~=nil then + if self.eff_feiji ~= nil then self.eff_feiji:Dispose() end effect:Dispose() @@ -1344,11 +1293,9 @@ function M:_Effect( type1 ,player) -- end end - - function M:UpdateRound(round) local total_round = self._room.room_config.Times - printlog("jefe total_round:",total_round) + printlog("jefe total_round:", total_round) self._text_round.text = string.format("%d / %d 局", round, total_round) end @@ -1382,7 +1329,7 @@ end function M:GetSpringSeats(player_info) local seat_list = {} printlog("OnResult...des888") - local card_max_length = 10 + local card_max_length = 10 printlog("OnResult...des999") for i = 1, #player_info do local player = player_info[i] @@ -1408,17 +1355,17 @@ function M:PlayCardEff(card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/"..card) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ChunTian/" .. card) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") end - if card_code_obj then - card_code_obj:SetScale(1, 1) - poker_obj:AddChild(card_code_obj) - card_code_obj.visible = true - end - + if card_code_obj then + card_code_obj:SetScale(1, 1) + poker_obj:AddChild(card_code_obj) + card_code_obj.visible = true + end + self.tween = TweenUtils.TweenFloat(0, 2340, cor_time, function(x) poker_back.rotationY = x poker_obj.rotationY = -180 + x @@ -1434,7 +1381,6 @@ function M:PlayCardEff(card) coroutine.wait(1) self._popEvent = true end) - end function M:ResetPoker() @@ -1445,8 +1391,7 @@ function M:ResetPoker() end function M:PlaySound(sex, path) - - local sex_path = ViewUtil.Sex_Chat[sex]-- 1 男 2 女 + local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 local sound_path = string.format("extend/poker/chuntian/sound/%s/%s.mp3", sex_path, path) ViewUtil.PlaySound("ChunTianNew_PK", sound_path) end @@ -1459,11 +1404,12 @@ function M:ChangeBgmMusic(bgm_index) end ViewUtil.PlayMuisc("ChunTianNew_PK", string.format("extend/poker/chuntian/sound/bgm%d.mp3", 1)) end -function M:OnPlayerEnter( ... ) - local arg = {...} + +function M:OnPlayerEnter(...) + local arg = { ... } local p = arg[1] - for i=1,#self._room.player_list do - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -1472,26 +1418,26 @@ function M:OnPlayerEnter( ... ) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end -- if p ~= self._room.self_player and self._room.room_config.people_num <= 4 and self._room.room_config.people_num >= 3 and self._gamectr:CheckGPS() then -- if self.distance_view then -- self.distance_view:Destroy() - -- end + -- end -- self.distance_view = PlayerDistanceView.new(true) -- self.distance_view:Show() -- end diff --git a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerBackView.lua b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerBackView.lua index 1834b4f5..99fd3468 100644 --- a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerBackView.lua +++ b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerBackView.lua @@ -20,15 +20,15 @@ local ChunTian_Record_Event = { local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/chuntian/bg/bg1', thumb = 'ui://Extend_Poker_ChunTian/table_bg1'}, - {id = 2, url = 'extend/poker/chuntian/bg/bg2', thumb = 'ui://Extend_Poker_ChunTian/table_bg2'}, - {id = 3, url = 'extend/poker/chuntian/bg/bg3', thumb = 'ui://Extend_Poker_ChunTian/table_bg3'} + { id = 1, url = 'extend/poker/chuntian/bg/bg1', thumb = 'ui://Extend_Poker_ChunTian/table_bg1' }, + { id = 2, url = 'extend/poker/chuntian/bg/bg2', thumb = 'ui://Extend_Poker_ChunTian/table_bg2' }, + { id = 3, url = 'extend/poker/chuntian/bg/bg3', thumb = 'ui://Extend_Poker_ChunTian/table_bg3' } } --- Create a new function M.new() - setmetatable(M, {__index = PKPlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKPlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'ChunTian_PlayBackView' self:init() @@ -42,7 +42,8 @@ function M:InitView(url) end self._gamectr = ControllerManager.GetController(GameController) UIPackage.AddPackage('extend/poker/chuntian/ui/Extend_Poker_ChunTian') - PKPlayBackView.InitView(self, 'ui://Extend_Poker_ChunTian/ChunTian_Main_' .. self._room.room_config.people_num, default_bg, bg_config) + PKPlayBackView.InitView(self, 'ui://Extend_Poker_ChunTian/ChunTian_Main_' .. self._room.room_config.people_num, + default_bg, bg_config) self._tex_round = self._view:GetChild('round') self._player_card_info = {} local _player_card_info = self._player_card_info @@ -54,8 +55,8 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = ChunTian_RightPanelView.new(self, rightpanel) + + self._rightPanelView = ChunTian_RightPanelView.new(self, rightpanel) rightpanel:GetChild("btn_setting").onClick:Clear() self._player_info = {} @@ -65,7 +66,7 @@ function M:InitView(url) _player_info[i] = PlayerInfoView.new(tem, self) end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -94,7 +95,7 @@ function M:NewPlayerPokerInfoView(view, index) end function M:FillRoomData(data) - print("hidezhanji 1111") + -- print("hidezhanji 1111") self._currentStep = 1 local room = DataManager.CurrenRoom local _player_card_info = self._player_card_info @@ -109,12 +110,12 @@ function M:FillRoomData(data) local head_info = self._player_info[self:GetPos(p.seat)] if p.total_hp then - print("hidezhanji 2222") + -- print("hidezhanji 2222") - head_info._view:GetChild('zhanji').visible=false + head_info._view:GetChild('zhanji').visible = false if room.hpOnOff == 1 or room:checkHpNonnegative() then - head_info._view:GetChild('zhanji').visible=true + head_info._view:GetChild('zhanji').visible = true head_info._view:GetChild('text_jifen').text = d2ad(p.total_hp) end end @@ -125,18 +126,17 @@ function M:FillRoomData(data) card_info:UpdateHandPoker(p.hand_list, false, true) end head_info:UpdatePiao(p.piao) - end self:UpdateRound() - + self:GenerateAllStepData(data) self:ShowStep(1) end function M:ShowStep(index) local step = self._step[index] - if step==nil then + if step == nil then return end for i = 1, #step.player_card_data do @@ -146,13 +146,12 @@ function M:ShowStep(index) p.hand_list = step.player_card_data[i].hand_list p.out_card_list = step.player_card_data[i].out_card_list p.hand_left_count = #p.hand_list - + if p.seat ~= self._room.self_player.seat then info:UpdateHandPoker(p.hand_list, false, true) else info:InitPoker(p.hand_list, false) end - end if step.cmd == ChunTian_Record_Event.Evt_OutCard then @@ -194,7 +193,8 @@ function M:ShowStep(index) end if step.cmd == ChunTian_Record_Event.Evt_Result then local Result = step.Result - self.result_view = ChunTian_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, Result.winseat, 0, Result.remaincards) + self.result_view = ChunTian_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, + Result.winseat, 0, Result.remaincards) local num = self._view:GetChildIndex(self._view:GetChild("panel_record")) self._view:AddChildAt(self.result_view._view, num) else @@ -257,6 +257,7 @@ function M:CmdPass(cmd, index) data.cmd = cmd.cmd data.current_out_seat = cmd.seat end + function M:Cmdresult(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd diff --git a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerSelfPokerInfoView.lua index 1b213409..da4369bf 100644 --- a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_PlayerSelfPokerInfoView.lua @@ -17,7 +17,7 @@ local CardView = { local function NewCardView(card, cardcodenum, cardcodeflower) local self = {} - setmetatable(self, {__index = CardView}) + setmetatable(self, { __index = CardView }) self.btn_card = card self.card_code_number = cardcodenum self.card_code_flower = cardcodeflower @@ -38,8 +38,8 @@ local ChunTian_PlayerSelfPokerInfoView = { local M = ChunTian_PlayerSelfPokerInfoView function M.new(view, mainView) - setmetatable(M, {__index = ChunTian_PlayerPokerInfoView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = ChunTian_PlayerPokerInfoView }) + local self = setmetatable({}, { __index = M }) self._view = view self._mainView = mainView self.gameCtr = ControllerManager.GetController(GameController) @@ -91,7 +91,7 @@ function M:InitPoker(pokerList, isPlayAni, open) -- self.zhizhanplay=0 -- self.zhizhanzdts=0 local cs = 1.25 - if DataManager.CurrenRoom.cardsize==0 then + if DataManager.CurrenRoom.cardsize == 0 then cs = 1.35 elseif DataManager.CurrenRoom.cardsize == 1 then cs = 1.25 @@ -102,7 +102,7 @@ function M:InitPoker(pokerList, isPlayAni, open) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end - -- print(vardump(self.card_list)) + -- -- print(vardump(self.card_list)) self.cor_init_poker = nil self.card_list = {} @@ -110,73 +110,72 @@ function M:InitPoker(pokerList, isPlayAni, open) if isPlayAni == true then self.cor_init_poker = coroutine.start( - function() - self._mainView._popEvent = false - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) - end - table.sort(pokerList) + function() + self._mainView._popEvent = false + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) + end + table.sort(pokerList) - for i = 1, #pokerList do - local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) - local card_flower_code = pokerList[i] - local btn_card = self:CreatPoker(card_number_code, cs, open) - local x, y = self._view.width / 2 + 100, -200 - btn_card:SetXY(x, y) - btn_card.alpha = 0 - btn_card.touchable = false - -- coroutine.wait(0.05) - self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - self.card_list[#self.card_list + 1] = card_view + for i = 1, #pokerList do + local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) + local card_flower_code = pokerList[i] + local btn_card = self:CreatPoker(card_number_code, cs, open) + local x, y = self._view.width / 2 + 100, -200 + btn_card:SetXY(x, y) + btn_card.alpha = 0 + btn_card.touchable = false + -- coroutine.wait(0.05) + self.cards_view:AddChild(btn_card) + local card_view = NewCardView(btn_card, card_number_code, card_flower_code) + self.card_list[#self.card_list + 1] = card_view - table.sort(self.card_list, tableSortNumber) + table.sort(self.card_list, tableSortNumber) - if i == #pokerList then - for j = 1, #self.card_list do - local card = self.card_list[j] - card.btn_card.touchable = true - if open ~= 1 then - -- body - self:AddCardMoveEvent(card) + if i == #pokerList then + for j = 1, #self.card_list do + local card = self.card_list[j] + card.btn_card.touchable = true + if open ~= 1 then + -- body + self:AddCardMoveEvent(card) + end end end end - end - for j = #self.card_list, 1, -1 do - -- ViewUtil.PlaySound('ChunTianNew_PK', 'extend/poker/runfast/sound/mopai.mp3') - local card_view = self.card_list[j] - card_view.index = j - self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) + for j = #self.card_list, 1, -1 do + -- ViewUtil.PlaySound('ChunTianNew_PK', 'extend/poker/runfast/sound/mopai.mp3') + local card_view = self.card_list[j] + card_view.index = j + self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) - card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card:SetScale(value, value) - end - ) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card.alpha = value - end - ) - card_view.btn_card.alpha = 1 - end + card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card:SetScale(value, value) + end + ) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card.alpha = value + end + ) + card_view.btn_card.alpha = 1 + end - self._mainView._popEvent = true - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + self._mainView._popEvent = true + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + end end - end - ) + ) else - for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) local card_flower_code = pokerList[i] @@ -200,7 +199,6 @@ function M:InitPoker(pokerList, isPlayAni, open) end function M:updatePoker() - local templist = {} for i = 1, #self.card_list do templist[#templist + 1] = self.card_list[i].card_code_flower @@ -249,21 +247,21 @@ function M:AddCardMoveEvent(card) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -285,25 +283,25 @@ function M:AddCardMoveEvent(card) if card.btn_card.touchable == true then send_card[#send_card + 1] = card self:SetBtnCardColor(card, 1) - --print(vardump(card)) + ---- print(vardump(card)) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -343,6 +341,7 @@ function M:AddCardMoveEvent(card) end ) end + function M:zhizhanxuanpai() --智障选牌 printlog("zhizhanxuanpai") -- body @@ -417,9 +416,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then - + card.btn_card.x < max_x + then self:SetBtnCardColor(card, 0.8) if #send_card1 == 0 then -- body @@ -448,8 +446,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then + card.btn_card.x < max_x + then -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) -- card.card_isTouchable = 1 -- ViewUtil.PlaySound("ChunTianNew_PK", "extend/poker/paodekuai/sound/click.mp3") @@ -470,7 +468,7 @@ function M:TouchMoving(context) end end end - --print(vardump(send_card1)) + ---- print(vardump(send_card1)) -- local send_card = {} -- self.send_card = {} -- for i = 1, #self.card_list do @@ -486,8 +484,8 @@ end function M:SetBtnCardColor(card, num) if card.btn_card:GetChildAt(0) ~= nil and card.btn_card:GetChildAt(0):GetChildAt(0) ~= nil and - card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil - then + card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil + then -- body card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(num, num, num) end @@ -536,10 +534,10 @@ function M:ShowOutCardOption(ctr_select, type, number, length, mustPutMaxCard, p -- self.zhizhanmustPutMaxCard=mustPutMaxCard -- self.zhizhanplay=play -- self.zhizhanzdts=zdts - + self.tips_click_count = 0 self.send_card = {} - + self.tips_card_list = self:GetCardTips(type, number, length, mustPutMaxCard) if #self.tips_card_list >= 1 then @@ -599,10 +597,9 @@ end function M:SetOutCardBlack() for i = 1, #self.out_card_list do local card = self.out_card_list[i] - if card and card:GetChildAt(0) and card:GetChildAt(0):GetChildAt(0) and card:GetChildAt(0):GetChildAt(0):GetChildAt(0) then - card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(0.7, 0.7, 0.7) - end - + if card and card:GetChildAt(0) and card:GetChildAt(0):GetChildAt(0) and card:GetChildAt(0):GetChildAt(0):GetChildAt(0) then + card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(0.7, 0.7, 0.7) + end end end @@ -632,13 +629,13 @@ function M:SetOutCardList(cardlist, isAnim) -- todo 出牌动画 local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - card.btn_card, - self.out_card_data['maxcount_x'], - 0.7 - ) + i, + #cardlist, + self.cards_view, + card.btn_card, + self.out_card_data['maxcount_x'], + 0.7 + ) card.btn_card:TweenMove(Vector2.New(pos.x, pos_y), time) -- self.tween = TweenUtils.TweenFloat(1, 0.7, time, function(x) -- card.btn_card:GetChildAt(0):SetScale(x, x) @@ -650,16 +647,16 @@ function M:SetOutCardList(cardlist, isAnim) end self.move_cor = coroutine.start( - function() - coroutine.wait(0.05) - for i = 1, #self.out_card_list do - local card = self.out_card_list[i] - self.cards_view:SetChildIndex(card, i - 1) + function() + coroutine.wait(0.05) + for i = 1, #self.out_card_list do + local card = self.out_card_list[i] + self.cards_view:SetChildIndex(card, i - 1) + end + coroutine.wait(0.1) + ViewUtil.PlaySound('ChunTian_PK', 'extend/poker/runfast/sound/chupai.mp3') end - coroutine.wait(0.1) - ViewUtil.PlaySound('ChunTian_PK', 'extend/poker/runfast/sound/chupai.mp3') - end - ) + ) else for i = 1, #cardlist do local poker_item = UIPackage.CreateObject('Extend_Poker_ChunTian', 'poker7') @@ -699,13 +696,13 @@ function M:SetOutCardList(cardlist, isAnim) self.cards_view:AddChild(poker_item) local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - poker_item, - self.out_card_data['maxcount_x'], - 1 - ) + i, + #cardlist, + self.cards_view, + poker_item, + self.out_card_data['maxcount_x'], + 1 + ) poker_item.xy = Vector2.New(pos.x, pos_y) self.out_card_list[#self.out_card_list + 1] = poker_item end @@ -785,10 +782,10 @@ function M:BtnEvent() end local send_card = {} self.send_card = {} - local currentCard={} + local currentCard = {} for i = 1, #self.card_list do local card = self.card_list[i] - table.insert(currentCard,card.card_code_flower) + table.insert(currentCard, card.card_code_flower) if card.btn_card.selected then send_card[#send_card + 1] = card.card_code_flower self.send_card[#self.send_card + 1] = card @@ -798,7 +795,7 @@ function M:BtnEvent() if #send_card == 0 then self:ErrorTip('请选择要出的牌 ') else - self.gameCtr:SendCard(send_card,currentCard) + self.gameCtr:SendCard(send_card, currentCard) end end ) @@ -851,10 +848,10 @@ function M:BtnEvent() local function click_tongyibaochun(sindex) self.ctr_baochun.selectedIndex = 0 - printlog("jefe:",sindex) + printlog("jefe:", sindex) self.gameCtr:SendTongYiBaoChun(sindex) end - + local btn_bubao = self._view:GetChild('btnbubao') btn_bubao.onClick:Set(function() @@ -875,8 +872,6 @@ function M:BtnEvent() btn_tongyi.onClick:Set(function() click_tongyibaochun(1) end) - - end function M:ShowTipsCard(index) @@ -897,7 +892,7 @@ function M:ShowTipsCard(index) end function M:GetHandCardOffset(count) - local start = -70---54 + local start = -70 ---54 local offset = 0 if count > 10 then @@ -916,6 +911,7 @@ function M:GetHandCardPos(index, card_count) x = start_x + (self.card_width + offset) * (index - 1) return Vector2.New(x, y) end + function M:GetHandCardPos1(index, card_count) local x, y = 0, -18 local offset = self:GetHandCardOffset(card_count) @@ -924,6 +920,7 @@ function M:GetHandCardPos1(index, card_count) x = start_x + (self.card_width + offset) * (index - 1) return x, y end + function M:ChangeOneCodeByFrom(card) local flower = math.floor(card / 100) local number = card % 100 @@ -943,13 +940,13 @@ function M:ErrorTip(error_text) self.cor_init_poker = nil self.cor_init_poker = coroutine.start( - function() - self.put_error_text.text = error_text - self.ctr_put_error.selectedIndex = 1 - coroutine.wait(2) - self.ctr_put_error.selectedIndex = 0 - end - ) + function() + self.put_error_text.text = error_text + self.ctr_put_error.selectedIndex = 1 + coroutine.wait(2) + self.ctr_put_error.selectedIndex = 0 + end + ) end --ChunTian_CardType @@ -969,13 +966,13 @@ end function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) local tip_list = {} local sidaisan = false - local touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } --printlog("aaaaaaaaaaaaacccccccccccccccccccc11111111111111111111111111111") --pt(self.card_list) local card_map, max_key = self:GetCardMapAndMaxKey(self.card_list) --printlog("aaaaaaaaaaaaaaaaaa222222222222222222222222222222222222222 ",max_key) --pt(card_map) - printlog("TIP type:",type) + printlog("TIP type:", type) if type == ChunTian_CardType.None then if DataManager.CurrenRoom.is_new_bout then tip_list = self:NewBoutTips(card_map) @@ -984,11 +981,11 @@ function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) elseif type == ChunTian_CardType.Bomb then tip_list, touch_key_list = self:CheckBomb(card_map, number, length) else - local list_type, list_bomb, list_tuituji = {}, {}, {} + local list_type, list_bomb, list_tuituji = {}, {}, {} local touch_type, touch_bomb, touch_tuituji - list_bomb, touch_bomb = self:CheckBomb(card_map, 0, 4) - local card_templist = membe_clone(self.card_list) - + list_bomb, touch_bomb = self:CheckBomb(card_map, 0, 4) + local card_templist = membe_clone(self.card_list) + if list_bomb ~= nil and tip_templist == nil then -- body for i = 1, #list_bomb do @@ -1007,9 +1004,9 @@ function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) pt(card_map) --推土机 list_tuituji, touch_tuituji = self:CheckTuiTuJi(card_map, 0, 6) - + local card_templist = membe_clone(self.card_list) - + if list_tuituji ~= nil and tip_templist == nil then -- body for i = 1, #list_tuituji do @@ -1057,7 +1054,6 @@ function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) -- body sidaisan = true end - elseif type == ChunTian_CardType.TuiTuJI then list_type, touch_type = self:CheckTuiTuJi(card_map, 0, 4) @@ -1085,8 +1081,6 @@ function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) -- body tip_list = self:GetMergeAllList(tip_list, tip_templist2) end - - end if (tip_templist ~= nil and sidaisan == false and #tip_templist >= 1) then @@ -1099,7 +1093,7 @@ end -- 合并多个list function M:GetMergeAllList(...) - local lists = {...} + local lists = { ... } local merge_list = {} for i = 1, #lists do local list_item = lists[i] @@ -1127,13 +1121,13 @@ function M:CheckOneCard(pokerMap, num, length) end for k, v in pairs(pokerMap) do if k > num and #v == 1 then - one_card_list[#one_card_list + 1] = {v[1]} + one_card_list[#one_card_list + 1] = { v[1] } touch_key_list[#touch_key_list + 1] = k end end for k, v in pairs(pokerMap) do if k > num and #v ~= 1 then - one_card_list[#one_card_list + 1] = {v[1]} + one_card_list[#one_card_list + 1] = { v[1] } touch_key_list[#touch_key_list + 1] = k end end @@ -1148,7 +1142,7 @@ function M:CheckOnePair(pokerMap, num, length) end for k, v in pairs(pokerMap) do -- 从三条和对子里面提取 if #v > 1 and k > num then - one_pair_list[#one_pair_list + 1] = {v[1], v[2]} + one_pair_list[#one_pair_list + 1] = { v[1], v[2] } touch_key_list[#touch_key_list + 1] = k end end @@ -1163,7 +1157,7 @@ function M:CheckThree(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v > 2 and k > num then - three_list[#three_list + 1] = {v[1], v[2], v[3]} + three_list[#three_list + 1] = { v[1], v[2], v[3] } touch_key_list[#touch_key_list + 1] = k end end @@ -1210,8 +1204,8 @@ function M:CheckThreeAndOne(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_one_list[#three_and_one_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_one_list[#three_and_one_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_one_list, touch_key_list @@ -1225,8 +1219,8 @@ function M:CheckThreeAndTwo(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_two_list[#three_and_two_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_two_list[#three_and_two_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_two_list, touch_key_list @@ -1343,7 +1337,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end if j == i + pair_length - 1 then plane_list[#plane_list + 1] = item_all_list - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end end @@ -1351,7 +1345,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end function M:SetNotTouchCard(touch_key_list, card_map) - local all_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local all_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } for i = 1, #all_key_list do local key = all_key_list[i] local isExsit = self:IsExistByList(touch_key_list, key) @@ -1394,13 +1388,14 @@ function M:GetCardMapAndMaxKey(pokerList) max_key = number end if map[number] == nil then - map[number] = {pokerList[i]} + map[number] = { pokerList[i] } else map[number][#map[number] + 1] = pokerList[i] end end return map, max_key end + function M:CheckOnes(pokerMap, num, length) local one_card_list = {} local touch_key_list = {} @@ -1418,7 +1413,7 @@ function M:CheckOnes(pokerMap, num, length) for i = 0, length - 1 do if l == k + i and l ~= 15 and l ~= 16 then -- body - text[#text + 1] = {p[1]} + text[#text + 1] = { p[1] } text2[#text2 + 1] = l if #text >= length then -- body @@ -1446,6 +1441,7 @@ function M:CheckOnes(pokerMap, num, length) end return one_card_list, touch_key_list, length end + function M:Clear() self:PlayScore(nil) self:SetOutCardInfo(nil, false) @@ -1456,9 +1452,9 @@ function M:Clear() end function M:ClearCheck() - self.card_list = {} + self.card_list = {} self.out_card_list = {} - self.cards_view:RemoveChildren(0, -1, true) + self.cards_view:RemoveChildren(0, -1, true) end function M:Destroy() diff --git a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_RightPanelView.lua b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_RightPanelView.lua index f478a884..698b51e9 100644 --- a/lua_probject/extend_project/extend/poker/chuntian/ChunTian_RightPanelView.lua +++ b/lua_probject/extend_project/extend/poker/chuntian/ChunTian_RightPanelView.lua @@ -1,7 +1,7 @@ local MainRightPanelView = require("Game.View.MainRightPanelView") local ChunTian_RightPanelView = {} local M = ChunTian_RightPanelView -local function __init(self,mainView,view) +local function __init(self, mainView, view) local right_panel = view local btn_setting = right_panel:GetChild("btn_setting") @@ -22,17 +22,17 @@ local function __init(self,mainView,view) end end) else - print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) + -- print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) if mainView.dismiss_room_cd_time > 0 then GameApplication.Instance:ShowTips("您还处于解散冷却时间当中,请稍后重试!") else - _gamectr:AskDismissRoom() + _gamectr:AskDismissRoom() end end end) end) - self._tex_data = right_panel:GetChild("tex_data") + self._tex_data = right_panel:GetChild("tex_data") self._tex_time = right_panel:GetChild("tex_time") self._pb_batteryLevel = right_panel:GetChild("pb_batteryLevel") self._xinhao = right_panel:GetController("xinhao") @@ -50,21 +50,22 @@ local function __init(self,mainView,view) self._total_time = 0 self:__UpdateTime() - + -- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true) -- self._timer:Start() end -function ChunTian_RightPanelView.new(mainView,view) - setmetatable(M, {__index = MainRightPanelView}) - local self = setmetatable({}, {__index = M}) - self.class = "ChunTian_RightPanelView" - __init(self,mainView,view) +function ChunTian_RightPanelView.new(mainView, view) + setmetatable(M, { __index = MainRightPanelView }) + local self = setmetatable({}, { __index = M }) + self.class = "ChunTian_RightPanelView" + __init(self, mainView, view) return self end + function M:__UpdateTime() self._tex_data.text = os.date("%Y-%m-%d") self._tex_time.text = os.date("%H:%M") - if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then + if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then self._pb_batteryLevel.value = GameApplication.Instance:GetBatteryLevel() end @@ -74,7 +75,7 @@ function M:__UpdateTime() local ping = _client:getAveragePingTime() if not ping then return end ping = math.floor(ping / 2) - if ping > 300 then ping =300 end + if ping > 300 then ping = 300 end if ping <= 100 then self.ctr_xh.selectedIndex = 0 elseif ping <= 300 then @@ -85,4 +86,4 @@ function M:__UpdateTime() self._tex_ping.text = ping .. "ms" end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/poker/chuntian/ExtendConfig.lua b/lua_probject/extend_project/extend/poker/chuntian/ExtendConfig.lua index 5b31c57d..05427a8a 100644 --- a/lua_probject/extend_project/extend/poker/chuntian/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/poker/chuntian/ExtendConfig.lua @@ -18,8 +18,8 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) self.class = "ExtendConfig" self.extend_id = 14 self._viewMap = {} @@ -38,13 +38,13 @@ function M:UnAssets() UIPackage.RemovePackage("extend/poker/chuntian/ui/Extend_Poker_ChunTian") ResourcesManager.UnLoadGroup("RunFase_PK") end - + local _gameInfo = nil function M:GetGameInfo() -if not _gameInfo then - _gameInfo = EXGameInfo.new() -end -return _gameInfo + if not _gameInfo then + _gameInfo = EXGameInfo.new() + end + return _gameInfo end local _ctr_game = nil @@ -59,13 +59,12 @@ function M:NewRoom() return ChunTian_Room.new() end - function M:GetIconUrl() return "ui://Extend_Poker_ChunTian/icon" -- end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = ChunTian_RoomConfig.new(_config) end @@ -78,20 +77,20 @@ function M:FillRoomData(s2croom) local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - - room.xipaiScore=_tableInfo["xipai_score"] + + room.xipaiScore = _tableInfo["xipai_score"] local _config = _tableInfo["config"] room.room_config = ChunTian_RoomConfig.new(_config) room.curren_round = _tableInfo["round"] - - if room.curren_round == 0 and reload then - room.curren_round = 1 + + if room.curren_round == 0 and reload then + room.curren_round = 1 end local playerList = _tableInfo["playerData"] - for i = 1,#playerList do + for i = 1, #playerList do local _jp = playerList[i] local p = ChunTian_Player.new() @@ -131,28 +130,25 @@ function M:FillRoomData(s2croom) room.owner_id = owner room.game_status = 0 if reload then - local reloadInfo = s2croom["reloadInfo"] - - + + local playing = reloadInfo["playing"] room.curren_turn_seat = reloadInfo["active_seat"] local info_list = reloadInfo["info_list"] if playing == true then - - room.CurnrenState = StateType.Palying - room.game_status=1 - + room.game_status = 1 + for i = 1, #info_list do local p = room:GetPlayerById(info_list[i]["playerid"]) if p == room.self_player then p.hand_list = reloadInfo["hand_card"] - p.open= reloadInfo["open"] + p.open = reloadInfo["open"] end p.hand_count = info_list[i]["card_size"] @@ -160,17 +156,17 @@ function M:FillRoomData(s2croom) p.outCards = info_list[i]["outCards"] local last_outcard = info_list[i]["last_outcard"] if last_outcard ~= nil and last_outcard[1] ~= 0 then - local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list,true) - local card_type,number,length,plan_three_count = _ctr_game:GetCardListInfo(out_card_list) - p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list,card_type,number,plan_three_count) + local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list, true) + local card_type, number, length, plan_three_count = _ctr_game:GetCardListInfo(out_card_list) + p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list, card_type, number, plan_three_count) else - p.out_card_list = {0} + p.out_card_list = { 0 } end end else - -- print("aaaaaaaaaaaaaaaa1111111111111111111111111") + -- -- print("aaaaaaaaaaaaaaaa1111111111111111111111111") --pt(s2croom) - room.game_status=1 + room.game_status = 1 room.CurnrenState = StateType.PalyingWait @@ -180,36 +176,33 @@ function M:FillRoomData(s2croom) for i = 1, #info_list do local playerData = info_list[i] local p = room:GetPlayerById(playerData["playerid"]) - + p.ready = playerData["certainseat"] == 1 and true or false local last_outcard = info_list[i]["last_outcard"] if last_outcard ~= nil and last_outcard[1] ~= 0 then - - local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list,true) - local card_type,number,length,plan_three_count = _ctr_game:GetCardListInfo(out_card_list) - p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list,card_type,number,plan_three_count) + local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list, true) + local card_type, number, length, plan_three_count = _ctr_game:GetCardListInfo(out_card_list) + p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list, card_type, number, plan_three_count) else - p.out_card_list = {0} + p.out_card_list = { 0 } end - + p.hand_list = info_list[i]["cards"] p.winscore = info_list[i]["winscore"] p.hand_count = info_list[i]["card_size"] - p.thisboomnum=info_list[i]["thisboomnum"] - p.open= info_list[i]["open"] + p.thisboomnum = info_list[i]["thisboomnum"] + p.open = info_list[i]["open"] p.handCards = info_list[i]["handCards"] p.outCards = info_list[i]["outCards"] - end + end end else room.CurnrenState = StateType.Ready end end - - function M:FillPlayBackData(pd_data) local room = DataManager.CurrenRoom local _tableInfo = pd_data["info"] @@ -224,7 +217,7 @@ function M:FillPlayBackData(pd_data) room.curren_turn_seat = active_seat room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = ChunTian_Player.new() p.seat = _jp["seat"] @@ -245,7 +238,7 @@ function M:FillPlayBackData(pd_data) p.hand_list = _hand_card p.hand_count = #_hand_card p.total_score = _jp["score"] - p.open= _jp["open"] + p.open = _jp["open"] p.hp_info = _jp["hp_info"] if _jp['hp_info'] then p.cur_hp = _jp.hp_info.cur_hp @@ -256,4 +249,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/poker/mushi/MuShi_GameController.lua b/lua_probject/extend_project/extend/poker/mushi/MuShi_GameController.lua index e5ae0d3b..52c3f817 100644 --- a/lua_probject/extend_project/extend/poker/mushi/MuShi_GameController.lua +++ b/lua_probject/extend_project/extend/poker/mushi/MuShi_GameController.lua @@ -19,8 +19,8 @@ local MuShi_GameController = {} local M = MuShi_GameController function M.new() - setmetatable(M, {__index = GameController}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = GameController }) + local self = setmetatable({}, { __index = M }) self:init("木虱") self.class = "MuShi_GameController" return self @@ -39,8 +39,8 @@ function M:RegisterEvt() -- self._eventmap[MuShi_Protocol.MuShi_Options] = self.OnOptions -- self._eventmap[MuShi_Protocol.MuShi_Index_Move] = self.OnIndexMove --self._eventmap[MuShi_Protocol.MuShi_Play_Succ] = self.OnPlaySucc - self._eventmap[MuShi_Protocol.MuShi_Put_Error] = self.OnPutError - self._eventmap[MuShi_Protocol.MuShi_Pass_Succ] = self.OnPassSucc + self._eventmap[MuShi_Protocol.MuShi_Put_Error] = self.OnPutError + self._eventmap[MuShi_Protocol.MuShi_Pass_Succ] = self.OnPassSucc self._eventmap[MuShi_Protocol.MuShi_Result] = self.OnResult self._eventmap[MuShi_Protocol.MuShi_Bomb_Score] = self.OnBombScore self._eventmap[MuShi_Protocol.MuShi_Piao_Tip] = self.OnPiaoTip @@ -61,15 +61,14 @@ function M:RegisterEvt() self._eventmap[MuShi_Protocol.GAME_EVT_CUOPAI_FINISH_RSP] = self.FinishCuoPai - -- self._eventmap[Protocol.GAME_EVT_READY] = self.OnExTendPlayerReady - + -- self._eventmap[Protocol.GAME_EVT_READY] = self.OnExTendPlayerReady end function M:OnExTendPlayerReady(evt_data) self._cacheEvent:Enqueue( function() local pid = evt_data['aid'] - local p = self._room:GetPlayerById(pid) + local p = self._room:GetPlayerById(pid) DispatchEvent(self._dispatcher, MuShi_GameEvent.OnReady, p.seat) end ) @@ -110,10 +109,10 @@ function M:SendBuPai(bupai) _client:send(MuShi_Protocol.MuShi_Send_Piao, _data) end -function M:SendCard(cards,currentCard) +function M:SendCard(cards, currentCard) local _data = {} _data["card"] = cards - _data["all_card"] = currentCard + _data["all_card"] = currentCard local _client = ControllerManager.GameNetClinet _client:send(MuShi_Protocol.MuShi_Send_Card, _data) end @@ -141,7 +140,7 @@ function M:ConformToNextGame() end function M:StarQiangZhuang() - printlog("开始抢庄====================================") + printlog("开始抢庄====================================") self._cacheEvent:Enqueue( function() DispatchEvent(self._dispatcher, MuShi_GameEvent.OnQiangZhuang) @@ -150,12 +149,12 @@ function M:StarQiangZhuang() end function M:FinishCuoPai(evt_data) - print("上报搓牌返回==================") + -- print("上报搓牌返回==================") local seat = evt_data["seat"] local card = evt_data["card"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnFinishCuoPai,seat,card) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnFinishCuoPai, seat, card) end ) end @@ -167,7 +166,7 @@ function M:OtherQiangZhuang(evt_data) local index = evt_data["index"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnOtherQiangZhuang,seat,index) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnOtherQiangZhuang, seat, index) end ) end @@ -179,17 +178,17 @@ function M:DingZhuang(evt_data) local score = evt_data["score"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnZhuang, seat,index,score) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnZhuang, seat, index, score) end ) end function M:StarBet(evt_data) - printlog("开始下注 ====================================",evt_data["seat"]) + printlog("开始下注 ====================================", evt_data["seat"]) local seat = evt_data["seat"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnStarBet,seat) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnStarBet, seat) end ) end @@ -202,18 +201,18 @@ function M:OtherBet(evt_data) local score = evt_data["mul"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnBet, seat,index,score) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnBet, seat, index, score) end ) end function M:TiQianStar(evt_data) - -- printlog("发起提前开始返回1111====================================") + -- printlog("发起提前开始返回1111====================================") local seat = evt_data["seat"] local agree = evt_data["agree"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnTiQian, seat,agree) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnTiQian, seat, agree) end ) end @@ -224,7 +223,7 @@ function M:OnAgreeGame(evt_data) local agree = evt_data["agree"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnAgree, seat,agree) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnAgree, seat, agree) end ) end @@ -268,10 +267,10 @@ function M:OnInitCard(evt_data) --local cardtype = evt_data["cardtype"] --local seat = evt_data["seat"] --local cardopen = evt_data["cardopen"] - + local playerAry = evt_data["playerAry"] - -- printlog(#playerAry) - -- pt(playerAry[1]) + -- printlog(#playerAry) + -- pt(playerAry[1]) local round = playerAry[1].round self._cacheEvent:Enqueue( function() @@ -282,7 +281,7 @@ function M:OnInitCard(evt_data) self._room.curren_round = round --self._room.curren_round = round --DispatchEvent(self._dispatcher, MuShi_GameEvent.OnInitCard, round, cardlist,cardtype,seat,cardopen) - DispatchEvent(self._dispatcher,MuShi_GameEvent.OnInitCard,round,playerAry) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnInitCard, round, playerAry) end ) end @@ -314,7 +313,8 @@ function M:OnPlaySucc(evt_data) player.hand_count = remain local card_type, number, length, plan_three_count = self:GetCardListInfo(out_card_list) player.out_card_list = self:GetSortOutCardList(out_card_list, card_type, number, plan_three_count) - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnPlaySucc, player, remain, card_type, number, otherList,length) + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnPlaySucc, player, remain, card_type, number, otherList, + length) end ) end @@ -324,7 +324,7 @@ function M:OnPassSucc(evt_data) self._cacheEvent:Enqueue( function() local p = self._room:GetPlayerBySeat(seat) - p.out_card_list = {0} + p.out_card_list = { 0 } DispatchEvent(self._dispatcher, MuShi_GameEvent.OnPassSucc, p) end ) @@ -339,6 +339,7 @@ function M:OnPutError(evt_data) end ) end + function M:TuoGuan(isTuo) local _data = {} _data["tuoguan"] = isTuo @@ -353,6 +354,7 @@ function M:Game_TuoGuan(evt_data) DispatchEvent(self._dispatcher, MuShi_GameEvent.Game_TuoGuan, tuoguan, seat) end) end + function M:OnIndexMove(evt_data) local seat = evt_data["index"] self._cacheEvent:Enqueue( @@ -372,7 +374,7 @@ function M:OnOptions(evt_data) function() local lastCardList = self:GetLastCardList(self._room.self_player.seat) local cardType, cardNum, cardLength = self:GetCardListInfo(lastCardList) - + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnOptions, play, cardType, cardNum, cardLength, pass) end ) @@ -389,7 +391,6 @@ function M:OnPiaoTip(evt_data) --local reload = evt_data["reload"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnPiaoTips) end ) @@ -404,19 +405,19 @@ function M:OnPiaoAction(evt_data) local seat = evt_data["seat"] local piao = evt_data["bupai"] local card = evt_data["card"] - + self._cacheEvent:Enqueue( - function() - DispatchEvent(self._dispatcher, MuShi_GameEvent.OnPiaoAction, seat,piao,card) + function() + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnPiaoAction, seat, piao, card) end ) end function M:OnResult(evt_data) - -- printlog("结算消息==========================》") + -- printlog("结算消息==========================》") --pt(evt_data) local result_type = evt_data["type"] --0小结算 1 大结算 2 解散房间 - + local info = evt_data["info"] local winseat = evt_data["winseat"] local remaincards = evt_data["remaincards"] @@ -431,7 +432,7 @@ function M:OnResult(evt_data) p.total_score = info[i]["score"] info[i]["self_user"] = p.self_user end - + DispatchEvent(self._dispatcher, MuShi_GameEvent.OnResult, over, info, winseat, remaincards) end ) @@ -468,6 +469,7 @@ function M:OnConfrimToNextGameSucc(evt_data) end ) end + function M:Game_TuoGuan(evt_data) local tuoguan = evt_data["tuoguan"] local seat = evt_data["seat"] @@ -475,6 +477,7 @@ function M:Game_TuoGuan(evt_data) DispatchEvent(self._dispatcher, MuShi_GameEvent.Game_TuoGuan, tuoguan, seat) end) end + function M:ChangeCodeByFrom(cardList, isSort) isSort = isSort or false local new_card_list = {} @@ -595,14 +598,13 @@ end --Bomb = 11 -- 牌型,大小, 长度 function M:GetCardListInfo(cardlist) - if #cardlist == 0 then return 0, 0, 0, 0 end -- 检测牌型 local card_type, card_num, card_length, plan_three_count = MuShi_CardType.None, 0, #cardlist, 0 local card_map = self:GetCardMapByList(cardlist) - + if #cardlist == 1 then card_type = MuShi_CardType.OneCard card_num = math.floor(cardlist[1] / 10) @@ -611,14 +613,12 @@ function M:GetCardListInfo(cardlist) card_num = math.floor(cardlist[1] / 10) elseif #cardlist == 3 then card_num = math.floor(cardlist[1] / 10) - if card_num==14 and DataManager.CurrenRoom.room_config.threeA==1 then + if card_num == 14 and DataManager.CurrenRoom.room_config.threeA == 1 then -- body card_type = MuShi_CardType.Bomb else card_type = MuShi_CardType.Three - end - elseif #cardlist == 4 then local max_key = 0 for k, v in pairs(card_map) do @@ -673,11 +673,9 @@ function M:GetCardListInfo(cardlist) else local one_count, two_count, three_count = 0, 0, 0 local max_one_key, max_two_key, max_three_key = 0, 0, 0 - + for k, v in pairs(card_map) do - if #v == 2 then - if k > max_two_key then max_two_key = k end @@ -687,7 +685,6 @@ function M:GetCardListInfo(cardlist) card_num = max_two_key end elseif #v == 1 then - if k > max_one_key then max_one_key = k end @@ -697,7 +694,6 @@ function M:GetCardListInfo(cardlist) card_num = max_one_key end elseif #v == 3 then - if max_three_key == 0 then max_three_key = k three_count = three_count + 1 @@ -707,10 +703,10 @@ function M:GetCardListInfo(cardlist) elseif k < max_three_key and k == max_three_key - 1 then max_three_key = k three_count = three_count + 1 - -- else - -- max_three_key = k + -- else + -- max_three_key = k end - + --three_count = three_count + 1 end end @@ -726,25 +722,17 @@ function M:GetCardListInfo(cardlist) -- card_num = max_three_key -- end plan_three_count = three_count - - if three_count * 3 == #cardlist then + + if three_count * 3 == #cardlist then card_type = MuShi_CardType.Plane card_num = max_three_key - - elseif three_count * 4 >= #cardlist and #cardlist%4==0 then + elseif three_count * 4 >= #cardlist and #cardlist % 4 == 0 then card_type = MuShi_CardType.PlaneAndOne card_num = max_three_key - - - elseif three_count * 5 >= #cardlist and #cardlist%5==0 then + elseif three_count * 5 >= #cardlist and #cardlist % 5 == 0 then card_type = MuShi_CardType.PlaneAndTwo card_num = max_three_key - - end - - - end return card_type, card_num, card_length, plan_three_count @@ -756,7 +744,7 @@ function M:GetCardMapByList(cardlist) local card = cardlist[i] local card_num = math.floor(cardlist[i] / 10) if card_map[card_num] == nil then - card_map[card_num] = {card} + card_map[card_num] = { card } else card_map[card_num][#card_map[card_num] + 1] = card end diff --git a/lua_probject/extend_project/extend/poker/mushi/MuShi_MainView.lua b/lua_probject/extend_project/extend/poker/mushi/MuShi_MainView.lua index 676a4a9c..d9a61b22 100644 --- a/lua_probject/extend_project/extend/poker/mushi/MuShi_MainView.lua +++ b/lua_probject/extend_project/extend/poker/mushi/MuShi_MainView.lua @@ -14,8 +14,8 @@ local MuShi_CardType = import(".MuShi_CardType") local FlyCoin = import(".FlyCoin") local M = {} function M.new() - setmetatable(M, {__index = MSMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MSMainView }) + local self = setmetatable({}, { __index = M }) self.class = "MuShi_MainView" self:init() self._gamectr = ControllerManager.GetController(GameController) @@ -24,19 +24,19 @@ end local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1'}, - {id = 2, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1'}, - {id = 3, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1'} + { id = 1, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1' }, + { id = 2, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1' }, + { id = 3, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1' } } local gameState = { - None = 0, - ROOM_STATUS_INIT = 1,--初始化 - ROOM_STATUS_START = 2,--开始 - ROOM_STATUS_QIANGZHUANG = 3,--抢庄 - ROOM_STATUS_XIAZHU = 4,--下注 - ROOM_STATUS_BUPAI = 5,--补牌 - ROOM_STATUS_FINISH = 6,--完成 + None = 0, + ROOM_STATUS_INIT = 1, --初始化 + ROOM_STATUS_START = 2, --开始 + ROOM_STATUS_QIANGZHUANG = 3, --抢庄 + ROOM_STATUS_XIAZHU = 4, --下注 + ROOM_STATUS_BUPAI = 5, --补牌 + ROOM_STATUS_FINISH = 6, --完成 } function M:InitView(url) @@ -48,7 +48,8 @@ function M:InitView(url) self._curren_msg = nil --room.room_config.people_num = 5 self.currenBank = -1 - MSMainView.InitView(self, "ui://Extend_Poker_MuShi/MuShi_Main_"..room.room_config.people_num,nil,1,default_bg,bg_config,nil,"ui://Extend_Poker_MuShi/SettingWindow1") + MSMainView.InitView(self, "ui://Extend_Poker_MuShi/MuShi_Main_" .. room.room_config.people_num, nil, 1, default_bg, + bg_config, nil, "ui://Extend_Poker_MuShi/SettingWindow1") local _room = DataManager.CurrenRoom local user_id = DataManager.SelfUser.account_id @@ -60,7 +61,7 @@ function M:InitView(url) tem.visible = false end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -72,11 +73,10 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = MuShi_RightPanelView.new(self, rightpanel) - for i=1,#self._room.player_list do - - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + + self._rightPanelView = MuShi_RightPanelView.new(self, rightpanel) + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -85,26 +85,26 @@ function M:InitView(url) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end - - + + self.ctr_state = self._view:GetController("state") - + self._ctr_action = self._view:GetController("action") self._tex_leftTime = self._view:GetChild("time"):GetChild("title") self.ctr_time = self._view:GetController("time") @@ -114,16 +114,16 @@ function M:InitView(url) self.btn_ready1 = self._view:GetChild("btn_ready1") self.btn_ready1.visible = false - + local _player_card_info = self._player_card_info for i = 1, room.room_config.people_num do local tem = self._view:GetChild("player_card_info_" .. i) _player_card_info[i] = self:NewPlayerCardInfoView(tem, i) end - + local list = room.player_list - printlog("#list#list ",#list) - if not room.self_player.ready and room.room_config.people_num ==#list then + printlog("#list#list ", #list) + if not room.self_player.ready and room.room_config.people_num == #list then self._ctr_action.selectedIndex = 1 else self._ctr_action.selectedIndex = 0 @@ -131,14 +131,14 @@ function M:InitView(url) self._left_time = 0 self.bgm_index = 1 local state = self._room.CurnrenState - -- printlog("aaaaaaaaaaaaaaaaawwwwwwwwwwwwwwww ",state) + -- printlog("aaaaaaaaaaaaaaaaawwwwwwwwwwwwwwww ",state) self.btnstar = self._view:GetChild("btnstar") self.btnstar.onClick:Set(function() --printlog("提前开始=================================") local _gamectr = ControllerManager.GetController(GameController) _gamectr:SendStar() end) - --print("11111111111111111111111122222222222222222222222222222222 ",room.CurnrenState) + ---- print("11111111111111111111111122222222222222222222222222222222 ",room.CurnrenState) if room.CurnrenState ~= StateType.PalyingWait then self._state.selectedIndex = state -- if room.CurnrenState == StateType.Palying then @@ -148,66 +148,62 @@ function M:InitView(url) else self._state.selectedIndex = StateType.Palying self:ReConnectForStart() - --self:ReconnectForClearing() + --self:ReconnectForClearing() end - + if room.CurnrenState ~= StateType.Ready then - --print("cccccccccccccccccc111111111111111111111111") + ---- print("cccccccccccccccccc111111111111111111111111") self._ctr_action.selectedIndex = 1 self.btnstar.visible = fasle else - --print("cccccccccccccccccc222222222222222222222222") + ---- print("cccccccccccccccccc222222222222222222222222") self.btnstar.visible = true end - - print("cccccccccccccccccc222222222222222222222222") - local jsBtn=self._view:GetChild("btn_back_jiesan") - printlog(jsBtn.visible) - printlog(jsBtn.touchable) - jsBtn.onClick:Set(function () - printlog("进入解散按钮=====》》》") + + -- print("cccccccccccccccccc222222222222222222222222") + local jsBtn = self._view:GetChild("btn_back_jiesan") + printlog(jsBtn.visible) + printlog(jsBtn.touchable) + jsBtn.onClick:Set(function() + printlog("进入解散按钮=====》》》") if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) - + self.InitCardList = {} self:ChangeBgmMusic() self:EventInit() - + local btn_rule = self._view:GetChild("right_panel"):GetChild("btn_log") self._view:GetChild('info_text'):GetChild('text').text = room.room_config:GetDes() self._view:GetChild('wanfa_text').text = '木虱' - + self:CuoPai() self:ResetCuoPai() self.isUpcuo = false - - self.coin = ResourcesManager.LoadObjectByGroup("extend/poker/mushi/effect/flycoin/flyCoinEffect.prefab",typeof(UnityEngine.GameObject),"extend/poker/mushi/effect/flycoin/flyCoinEffect") + + self.coin = ResourcesManager.LoadObjectByGroup("extend/poker/mushi/effect/flycoin/flyCoinEffect.prefab", + typeof(UnityEngine.GameObject), "extend/poker/mushi/effect/flycoin/flyCoinEffect") printlog("创建金币示例===》》》》") printlog(self.coin) - printlog("self.ctr_state.selectedIndex ",self.ctr_state.selectedIndex," ") + printlog("self.ctr_state.selectedIndex ", self.ctr_state.selectedIndex, " ") -- self.testcard = self._view:GetChild("testcard") -- self.test = self._view:GetChild("test") -- self.endCard = self._view:GetChild("n119") -- self.test.onClick:Set(function() -- self:Test() -- end) - -- printlog("11111111111111111 ",self.endCard.displayObject.gameObject.transform:InverseTransformPoint(self._view.displayObject.gameObject.transform.position)) + -- printlog("11111111111111111 ",self.endCard.displayObject.gameObject.transform:InverseTransformPoint(self._view.displayObject.gameObject.transform.position)) -- pt(self.endCard.displayObject.gameObject.transform:InverseTransformPoint(self._view.displayObject.gameObject.transform.position)) - - - end - -- function M:OnMuShiUpdate() -- -- for i = 1, #self._room.player_list do -- -- local player = self._room.player_list[i] @@ -219,36 +215,36 @@ end function M:Test() --local endCard = self._player_card_info[1].endcard.displayObject.gameObject.transform.position --local temp = self._view.displayObject.gameObject.transform:InverseTransformPoint(endCard) - -- self.testcard:TweenMove(Vector2(temp.x,temp.y * -1), 0.10) --- printlog("是否存在==》》》》》",self.testcard:TweenMove(self.endCard.xy,1).OnComplete) --- self.testcard:TweenMove(self.endCard.xy,1):OnComplete(function () --- printlog("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr") --- end) --- printlog("2222222222222222222222 ",self.endCard.xy.x," ",self.endCard.xy.y) + -- self.testcard:TweenMove(Vector2(temp.x,temp.y * -1), 0.10) + -- printlog("是否存在==》》》》》",self.testcard:TweenMove(self.endCard.xy,1).OnComplete) + -- self.testcard:TweenMove(self.endCard.xy,1):OnComplete(function () + -- printlog("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr") + -- end) + -- printlog("2222222222222222222222 ",self.endCard.xy.x," ",self.endCard.xy.y) end -function M:PlayFaPai(seat,cardlist,cardtype) +function M:PlayFaPai(seat, cardlist, cardtype) local card_info = self._player_card_info[self:GetPos(seat)] - local endPos = Vector3(0,0,0) + local endPos = Vector3(0, 0, 0) coroutine.start(function() - --coroutine.wait(0.2) - for i=1,#cardlist do + --coroutine.wait(0.2) + for i = 1, #cardlist do --printlog("ttttttttttttttt1111111111111111111111111111111") - endPos = card_info.cards_view:GetChildAt(i-1).displayObject.gameObject.transform.position + endPos = card_info.cards_view:GetChildAt(i - 1).displayObject.gameObject.transform.position local obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/00") - self._view:AddChild(obj) - obj:Center() - obj:SetScale(0.8,0.8) + self._view:AddChild(obj) + obj:Center() + obj:SetScale(0.8, 0.8) endPos = self._view.displayObject.gameObject.transform:InverseTransformPoint(endPos) - obj:TweenMove(Vector2(endPos.x,-1*endPos.y),0.2):OnComplete(function () + obj:TweenMove(Vector2(endPos.x, -1 * endPos.y), 0.2):OnComplete(function() obj:Dispose() - -- card_info.cards_view:GetChildAt(i-1).visible = true - card_info:ShowCard(i-1) + -- card_info.cards_view:GetChildAt(i-1).visible = true + card_info:ShowCard(i - 1) end) ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_fapai.mp3") coroutine.wait(0.1) end - end) + end) end function M:CuoPai() @@ -262,22 +258,22 @@ function M:CuoPai() self.btnCuoPai.onTouchEnd:Set(handler(self, self.__OnDragEnd)) self.beginX = self.n4.x self.beginY = self.n4.y - self.btnX=self.n4.x + self.btnX = self.n4.x self.btnY = self.n4.y - + self.lastX = self.n4.x self.lastY = self.n4.y self.initBtnX = self.n4.x self.initBtnY = self.n4.y self.cuopai.visible = false - -- print("self.btnY ",self.btnY) + -- -- print("self.btnY ",self.btnY) end function M:ResetCuoPai() self.n4.x = self.beginX self.n4.y = self.beginY - self.btnX=self.beginX + self.btnX = self.beginX self.btnY = self.beginY self.cuopai.visible = false if self.cuoCorout ~= nil then @@ -287,27 +283,26 @@ function M:ResetCuoPai() end function M:SetCuoPai(poker) - self.iconCuo.icon = "ui://Extend_Poker_MuShi/ms_poker_cuo_"..poker + self.iconCuo.icon = "ui://Extend_Poker_MuShi/ms_poker_cuo_" .. poker self:ResetCuoPai() self.cuopai.visible = true end function M:onTouchBegin(context) - self.lastX = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)).x - self.lastY = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)).y + self.lastX = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)).x + self.lastY = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)).y end -function M:onTouchMove(context) - local xy = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - local tempx = xy.x-self.lastX - local tempy = xy.y-self.lastY +function M:onTouchMove(context) + local xy = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + local tempx = xy.x - self.lastX + local tempy = xy.y - self.lastY + - if self.n4.y == self.initBtnY then - if tempx >= 0 then - local tempCardX = self.btnX+(xy.x-self.lastX) - --print("cccccccccccc1111111111111111 ;",tempCardX," ",self.btnX) + local tempCardX = self.btnX + (xy.x - self.lastX) + ---- print("cccccccccccc1111111111111111 ;",tempCardX," ",self.btnX) if tempCardX <= 510 then self.n4.x = tempCardX self.btnX = self.n4.x @@ -315,17 +310,16 @@ function M:onTouchMove(context) if (not self.isUpcuo) then self.isUpcuo = true local _gamectr = ControllerManager.GetController(GameController) - print("===========================上报搓牌=====================") + -- print("===========================上报搓牌=====================") _gamectr:SendCuo() self:ResetCuoPai() - end self.n4.x = 510 self.btnX = self.n4.x end else - local tempCardX = self.btnX+(xy.x-self.lastX) - if tempCardX > self.initBtnX then + local tempCardX = self.btnX + (xy.x - self.lastX) + if tempCardX > self.initBtnX then self.n4.x = tempCardX self.btnX = self.n4.x else @@ -333,13 +327,12 @@ function M:onTouchMove(context) self.btnX = self.n4.x end end - end if self.n4.x == self.initBtnX then - if tempy >=0 then - local tempCardY =self.btnY+(xy.y-self.lastY) - --print("11111111111111111111 ;",tempCardY," ",self.btnY) + if tempy >= 0 then + local tempCardY = self.btnY + (xy.y - self.lastY) + ---- print("11111111111111111111 ;",tempCardY," ",self.btnY) if tempCardY < 276 then self.n4.y = tempCardY self.btnY = self.n4.y @@ -348,8 +341,8 @@ function M:onTouchMove(context) self.btnY = self.n4.y end else - local tempCardY =self.btnY+(xy.y-self.lastY) - --print("22222222222222222222 ;",tempCardY," ",self.btnY) + local tempCardY = self.btnY + (xy.y - self.lastY) + ---- print("22222222222222222222 ;",tempCardY," ",self.btnY) if tempCardY > self.initBtnY then self.n4.y = tempCardY self.btnY = self.n4.y @@ -359,20 +352,20 @@ function M:onTouchMove(context) end end end - + self.lastX = xy.x self.lastY = xy.y end function M:__OnDragEnd(context) - local xy = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - if ((xy.x-self.lastX) < 150 and self.n4.y == self.initBtnY) then + local xy = self.cuopai:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + if ((xy.x - self.lastX) < 150 and self.n4.y == self.initBtnY) then self.n4.x = self.beginX self.n4.y = self.beginY - self.btnX=self.beginX + self.btnX = self.beginX self.btnY = self.beginY end - -- printlog("ttttttttt222222222222222222 ",xy.x- self.beginX," ",xy.y-self.beginY) + -- printlog("ttttttttt222222222222222222 ",xy.x- self.beginX," ",xy.y-self.beginY) end function M:NewPlayerCardInfoView(tem, index) @@ -380,7 +373,6 @@ function M:NewPlayerCardInfoView(tem, index) return MuShi_PlayerSelfPokerInfoView.new(tem, self) end return MuShi_PlayerPokerInfoView.new(tem, self) - end function M:PlayCardEff(card) @@ -397,10 +389,10 @@ function M:PlayCardEff(card) poker_back.visible = false -- selfcard_code_obj - if DataManager.CurrenRoom.room_config.config.laizi == 1 then - local card = 500+card%100 + if DataManager.CurrenRoom.room_config.config.laizi == 1 then + local card = 500 + card % 100 --printlog("鬼牌=++++++++++++++++++++++++++++",card," ",math.floor(card / 100)," ",card%15) - self.guiCard = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/"..card) + self.guiCard = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/" .. card) else end if self.guiCard then @@ -424,13 +416,11 @@ function M:PlayCardEff(card) coroutine.wait(1) self._popEvent = true end) - end - function M:OnPlayerReady(...) --printlog("玩家准备6++++++++++++++++++++") - local arg = {...} + local arg = { ... } local p = arg[1] local _room = self._room local _player_info = self._player_info @@ -456,62 +446,61 @@ function M:Clear() if self.result_view ~= nil then self.result_view:Destroy() self.result_view = nil - end + end self.btnstar.visible = false local list = self._room.player_list for i = 1, #list do local p = list[i] - local head_info = self._player_info[self:GetPos(p.seat)] + local head_info = self._player_info[self:GetPos(p.seat)] p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() - head_info:Ready(false) - end + head_info:Ready(false) + end end -function M:PlayZhuangEffect() +function M:PlayZhuangEffect() if self.currenBank == -1 then return end self.zhuangEffect = nil local playerList = {} for _, player in ipairs(self._room.player_list) do local player_head = self._player_info[self:GetPos(player.seat)] - table.insert(playerList,player_head) + table.insert(playerList, player_head) end local kIndex = 0 local round = 4 if #playerList > 4 then round = 2 end - local bCurren = #playerList*round + self.currenBank + local bCurren = #playerList * round + self.currenBank self.zhuangEffect = coroutine.start(function() while true do - coroutine.wait(0.14) + coroutine.wait(0.14) ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_randbanker.mp3") kIndex = kIndex + 1 local k = kIndex % #playerList - if k == 0 then k =#playerList end - for i=1,#playerList do + if k == 0 then k = #playerList end + for i = 1, #playerList do playerList[i]:SetKuang(false) end playerList[k]:SetKuang(true) if kIndex >= bCurren then - for i=1,#playerList do + for i = 1, #playerList do playerList[i]:SetKuang(false) end local player_head = self._player_info[self:GetPos(self.currenBank)] - -- player_head:SetKuang(true) - -- local head_info = self._player_info[self:GetPos(self.currenBank)] - -- head_info:MarkBank(true) + -- player_head:SetKuang(true) + -- local head_info = self._player_info[self:GetPos(self.currenBank)] + -- head_info:MarkBank(true) if self.zhuangEffect then coroutine.stop(self.zhuangEffect) self.zhuangEffect = nil - player_head:MarkBank(true) + player_head:MarkBank(true) return end end end - end) end @@ -522,16 +511,7 @@ function M:EventInit() local _player_card_info = self._player_card_info local _room = self._room _gamectr:AddEventListener(MuShi_GameEvent.OnMingCard, function(...) - local arg = {...} - local card = arg[1] - self.ctr_state.selectedIndex = 1 - self.ctr_card_eff.selectedIndex = 1 - self:PlayCardEff(card) - self.btn_ready1.visible = false - end) - - _gamectr:AddEventListener(MuShi_GameEvent.OnGuiPai,function (...) - local arg = {...} + local arg = { ... } local card = arg[1] self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 1 @@ -539,39 +519,47 @@ function M:EventInit() self.btn_ready1.visible = false end) - _gamectr:AddEventListener(MuShi_GameEvent.OnAgree,function (...) - local arg = {...} + _gamectr:AddEventListener(MuShi_GameEvent.OnGuiPai, function(...) + local arg = { ... } + local card = arg[1] + self.ctr_state.selectedIndex = 1 + self.ctr_card_eff.selectedIndex = 1 + self:PlayCardEff(card) + self.btn_ready1.visible = false + end) + + _gamectr:AddEventListener(MuShi_GameEvent.OnAgree, function(...) + local arg = { ... } local seat = arg[1] local agree = arg[2] end) - _gamectr:AddEventListener(MuShi_GameEvent.OnReady,function (...) - local arg = {...} + _gamectr:AddEventListener(MuShi_GameEvent.OnReady, function(...) + local arg = { ... } local seat = arg[1] if seat == self._room.self_player.seat then printlog("aaaaaaaaaaaaaaaaaaaaaaaa1111111111111") self.btn_ready1.visible = false end end) - - _gamectr:AddEventListener(MuShi_GameEvent.OnTiQian,function (...) + + _gamectr:AddEventListener(MuShi_GameEvent.OnTiQian, function(...) --printlog("发起提前开始返回2222====================================") - local arg = {...} + local arg = { ... } local seat = arg[1] local agree = arg[2] - + local _gamectr = ControllerManager.GetController(GameController) - if (seat ~= self._room.self_player.seat and self._curren_msg ==nil) then + if (seat ~= self._room.self_player.seat and self._curren_msg == nil) then self._curren_msg = UIPackage.CreateObjectFromURL('ui://Common/MessageBox') self._view:AddChild(self._curren_msg) self._curren_msg:Center() self._curren_msg:GetChild('tex_message').text = '确定要提前开始吗?' self._curren_msg:GetChild('btn_ok').onClick:Set( - function() + function() _gamectr:AgreeStar(1) self._curren_msg:Dispose() self._curren_msg = nil - end ) self._curren_msg:GetChild('btn_close').onClick:Set( @@ -583,11 +571,11 @@ function M:EventInit() ) end end) - - + + _gamectr:AddEventListener(MuShi_GameEvent.OnInitCard, function(...) self.btn_ready1.visible = false - local arg = {...} + local arg = { ... } local round = arg[1] -- local cardlist = arg[2] -- local cardtype = arg[3] @@ -599,7 +587,7 @@ function M:EventInit() self.result_view:Destroy() self.result_view = nil end - + --self._player_card_info[1]:HidePiao() self.btnstar.visible = false -- if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then @@ -607,12 +595,12 @@ function M:EventInit() -- self.MypokerList = cardlist -- end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 --self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -622,7 +610,7 @@ function M:EventInit() self:UpdateRound(round) ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/fapai.mp3") - for i=1,#info do + for i = 1, #info do local seat = info[i]["seat"] local cardlist = info[i]["cards"] local cardtype = info[i]["cardtype"] @@ -631,7 +619,7 @@ function M:EventInit() head_info:Ready(false) local card_info = self._player_card_info[self:GetPos(seat)] card_info:Clear() - card_info:InitPoker(cardlist,cardtype,cardopen) + card_info:InitPoker(cardlist, cardtype, cardopen) -- if seat == self._room.self_player.seat then -- self:PlayFaPai(seat,cardlist,cardtype) -- end @@ -639,35 +627,35 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.2) - for i=1,#info do + for i = 1, #info do local seat = info[i]["seat"] local cardlist = info[i]["cards"] local cardtype = info[i]["cardtype"] local cardopen = info[i]["cardopen"] local head_info = self._player_info[self:GetPos(seat)] - self:PlayFaPai(seat,cardlist,cardtype) + self:PlayFaPai(seat, cardlist, cardtype) coroutine.wait(0.2) end - end) + end) -- local list = _room.player_list -- local head_info = self._player_info[self:GetPos(seat)] -- --head_info:FillData(seat) -- head_info:Ready(false) -- local card_info = self._player_card_info[self:GetPos(seat)] -- card_info:Clear() - -- card_info:InitPoker(cardlist,cardtype,cardopen) + -- card_info:InitPoker(cardlist,cardtype,cardopen) -- if seat == self._room.self_player.seat then -- self:PlayFaPai(seat,cardlist,cardtype) -- end end) - + _gamectr:AddEventListener(MuShi_GameEvent.OnErrorTip, function(...) - local arg = {...} + local arg = { ... } local error_str = arg[1] self._player_card_info[1]:ErrorTip(error_str) -- self._player_card_info[1]:ResetPoker() end) - + _gamectr:AddEventListener(MuShi_GameEvent.OnPiaoTips, function(...) self.btn_ready1.visible = false local player_card_info = self._player_card_info[1] @@ -680,7 +668,7 @@ function M:EventInit() _gamectr:AddEventListener(MuShi_GameEvent.OnPiaoAction, function(...) self.btn_ready1.visible = false - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[3] self.isUpcuo = false @@ -691,8 +679,7 @@ function M:EventInit() card_info:AddPoker(piao) end - if (arg[2] == 3) and self._room.self_player.seat == seat then - + if (arg[2] == 3) and self._room.self_player.seat == seat then self:SetCuoPai(piao) -- self.cuoCorout = coroutine.start(function() -- coroutine.wait(5) @@ -700,21 +687,21 @@ function M:EventInit() -- _gamectr:SendCuo() -- end) end - if self._room.self_player.seat == seat then + if self._room.self_player.seat == seat then local player_card_info = self._player_card_info[1] player_card_info:ChangeCtrBuPai(0) end local player1 = self._room:GetPlayerBySeat(seat) if (arg[2] == 1) and seat == self._room.self_player.seat then - self:PlaySound(player1.self_user.sex,"ms_sound_bupai") + self:PlaySound(player1.self_user.sex, "ms_sound_bupai") elseif (arg[2] == 2) and seat == self._room.self_player.seat then - self:PlaySound(player1.self_user.sex,"ms_sound_kaipai") + self:PlaySound(player1.self_user.sex, "ms_sound_kaipai") end end) _gamectr:AddEventListener(MuShi_GameEvent.OnFinishCuoPai, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] @@ -722,68 +709,67 @@ function M:EventInit() card_info:AddPoker(card) self:ResetCuoPai() end) - - -- 托管 - _gamectr:AddEventListener(MuShi_GameEvent.Game_TuoGuan, function(...) - local arg = {...} + + -- 托管 + _gamectr:AddEventListener(MuShi_GameEvent.Game_TuoGuan, function(...) + local arg = { ... } local tuoguan = arg[1] local seat = arg[2] - + local tuoguanzhong = self._view:GetChild("tuoguanzhong") local zhezhao = self._view:GetChild("n109") local head_info = self._player_info[self:GetPos(seat)] if (tuoguan == 1) then - if (seat == self._room.self_player.seat ) then + if (seat == self._room.self_player.seat) then tuoguanzhong.visible = true - + zhezhao.visible = true zhezhao.onClick:Set(function() _gamectr:TuoGuan(0) end) else head_info._view:GetController("tuoguan").selectedIndex = 1 - end + end else if (seat == self._room.self_player.seat) then tuoguanzhong.visible = false - zhezhao.visible = false + zhezhao.visible = false else head_info._view:GetController("tuoguan").selectedIndex = 0 end end end) _gamectr:AddEventListener(MuShi_GameEvent.OnResult, function(...) - - local arg = {...} + local arg = { ... } local over = arg[1] local info = arg[2] local win_seat = arg[3] local remaincards = arg[4] - + local player_card_info = self._player_card_info[1] player_card_info:ChangeCtrBuPai(0) - if remaincards then - -- body + if remaincards then + -- body end if self._cor_sound ~= nil then coroutine.stop(self._cor_sound) self._cor_sound = nil end - - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) + + if self.destory_win ~= nil then + coroutine.stop(self.destory_win) end if self.WinItem_view1 ~= nil then self.WinItem_view1:Dispose() self.WinItem_view1 = nil end - - + + self.destory_win = nil self.destory_win = coroutine.start(function() - -- print("11111111111111") + -- -- print("11111111111111") -- coroutine.wait(1) - if self._room.self_player.seat == win_seat then + if self._room.self_player.seat == win_seat then local sprint_seat_list = self:GetSpringSeats(info) if #sprint_seat_list > 0 then local url = "ui://Extend_Poker_MuShiNew/Spring" @@ -794,110 +780,105 @@ function M:EventInit() ViewUtil.PlaySound("MuShi_PK", "base/common/sound/win new.mp3") end -- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_MuShiNew/Spring" or "ui://Extend_Poker_MuShiNew/Win_Mine" - - else local beigang = false - if #self:GetSpringSeats(info)>0 then - for i=1,#self:GetSpringSeats(info) do - if self:GetSpringSeats(info)[i]==self._room.self_player.seat then - local url = "ui://Extend_Poker_MuShiNew/spring2" + if #self:GetSpringSeats(info) > 0 then + for i = 1, #self:GetSpringSeats(info) do + if self:GetSpringSeats(info)[i] == self._room.self_player.seat then + local url = "ui://Extend_Poker_MuShiNew/spring2" self.WinItem_view = UIPackage.CreateObjectFromURL(url) self._view:AddChild(self.WinItem_view) self.WinItem_view:Center() self.WinItem_view:GetTransition("t0"):Play() - beigang=true + beigang = true end end - end - end for i = 1, #info do - -- coroutine.wait(0.3) - --print("player.cardMul===============",player.cardMul) + -- coroutine.wait(0.3) + ---- print("player.cardMul===============",player.cardMul) local player = info[i] local p = self._room:GetPlayerBySeat(player.seat) local head_info = self._player_info[self:GetPos(player.seat)] local card_info = self._player_card_info[self:GetPos(player.seat)] - card_info:SetCarType(player.cardType,player.cardPoint,player.cardMul) + card_info:SetCarType(player.cardType, player.cardPoint, player.cardMul) local player1 = self._room:GetPlayerBySeat(player.seat) if self._room.self_player.seat == player.seat then - self:PlayCardTypeVoice(player1.self_user.sex,player.cardType,player.cardPoint) - end + self:PlayCardTypeVoice(player1.self_user.sex, player.cardType, player.cardPoint) + end end self:FlyCoinByInfo(info) - coroutine.wait(0.1*#info) - for i = 1, #info do - local player = info[i] - local p = self._room:GetPlayerBySeat(player.seat) - local head_info = self._player_info[self:GetPos(player.seat)] - local card_info = self._player_card_info[self:GetPos(player.seat)] - - if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then - p.hp_info = player.hp_info - head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) - head_info._view:GetChild('zhanji').visible = true - local num = player.hp_info.total_hp - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(player.hp_info.total_hp) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = d2ad(player.hp_info.total_hp) - end - card_info:PlayScore(d2ad(player.hp_info.round_actual_hp), false, win_seat == player.seat) - else - local rt = 1 - if self._room.hpOnOff == 1 then - rt = self._room.score_times - end - if over == 1 and self._room.hpOnOff == 1 then - head_info:UpdateScore(player.score / 10) --不可负分 - else - head_info:UpdateScore(player.score * rt) - end - card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) - end - - - if player.seat ~= self._room.self_player.seat then - card_info:UpdateHandPoker(player.cards, false, true) - card_info:SetRemainCardNumber(false) - else - - end - - end - coroutine.wait(0.5) - for i = 1, #info do + coroutine.wait(0.1 * #info) + for i = 1, #info do + local player = info[i] + local p = self._room:GetPlayerBySeat(player.seat) + local head_info = self._player_info[self:GetPos(player.seat)] + local card_info = self._player_card_info[self:GetPos(player.seat)] + + if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then + p.hp_info = player.hp_info + head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) + head_info._view:GetChild('zhanji').visible = true + local num = player.hp_info.total_hp + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. d2ad(player.hp_info.total_hp) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = d2ad(player.hp_info.total_hp) + end + card_info:PlayScore(d2ad(player.hp_info.round_actual_hp), false, win_seat == player.seat) + else + local rt = 1 + if self._room.hpOnOff == 1 then + rt = self._room.score_times + end + if over == 1 and self._room.hpOnOff == 1 then + head_info:UpdateScore(player.score / 10) --不可负分 + else + head_info:UpdateScore(player.score * rt) + end + card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) + end + + + if player.seat ~= self._room.self_player.seat then + card_info:UpdateHandPoker(player.cards, false, true) + card_info:SetRemainCardNumber(false) + else + + end + end + coroutine.wait(0.5) + for i = 1, #info do local player = info[i] local p = self._room:GetPlayerBySeat(player.seat) local head_info = self._player_info[self:GetPos(player.seat)] local card_info = self._player_card_info[self:GetPos(player.seat)] if player.seat == self._room.self_player.seat then - if (player.winscore>0) then + if (player.winscore > 0) then printlog("cccccccccccc22222222222222222222222") - local url = "ui://Extend_Poker_MuShi/FzEffect" - self.WinItem_view1 = UIPackage.CreateObjectFromURL(url) - self._view:AddChild(self.WinItem_view1) - self.WinItem_view1:Center() - self.WinItem_view1:GetTransition("t2"):Play() - ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_win.mp3") - end - end - end + local url = "ui://Extend_Poker_MuShi/FzEffect" + self.WinItem_view1 = UIPackage.CreateObjectFromURL(url) + self._view:AddChild(self.WinItem_view1) + self.WinItem_view1:Center() + self.WinItem_view1:GetTransition("t2"):Play() + ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_win.mp3") + end + end + end self:ChangeBgmMusic(1) -- if over == 0 then if #self:GetSpringSeats(info) > 0 then - -- print("222222222222222222") + -- -- print("222222222222222222") --coroutine.wait(1) else - -- print("333333333333333333") + -- -- print("333333333333333333") -- coroutine.wait(2) end coroutine.wait(1) - if (over == 0) then-- + if (over == 0) then -- -- if self._room.self_player.entrust and self._room.self_player.entrust == false then -- self.btn_ready1.visible = true -- end @@ -910,9 +891,9 @@ function M:EventInit() self.btn_ready1.visible = false local _gamectr = ControllerManager.GetController(GameController) _gamectr:ConformToNextGame() - end) + end) else - self.result_view = MuShi_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 1,nil) + self.result_view = MuShi_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 1, nil) self.result_view:Show() end --self.result_view = MuShi_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, remaincards) @@ -927,40 +908,37 @@ function M:EventInit() end if self._room.self_player.entrust == true and self.result_view then - local btn_confirm = self.result_view._view:GetChild("btn_confirm") + local btn_confirm = self.result_view._view:GetChild("btn_confirm") btn_confirm.onClick:Call() end - - end) - if over==1 then + if over == 1 then -- body self:UnmarkSelfTuoguan() ControllerManager.ChangeController(LoddyController) end - if self.guiCard ~=nil then + if self.guiCard ~= nil then self.guiCard:Dispose() end end) - - _gamectr:AddEventListener(MuShi_GameEvent.OnResultByDissolve, function(...) - - local arg = {...} - local over = arg[1] - local info = arg[2] - local winseat = arg[3] - local dissolve = arg[4] - self.result_view = MuShi_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve,nil) - self.result_view:Show() - ControllerManager.ChangeController(LoddyController) - self:UnmarkSelfTuoguan() + _gamectr:AddEventListener(MuShi_GameEvent.OnResultByDissolve, function(...) + local arg = { ... } + local over = arg[1] + local info = arg[2] + local winseat = arg[3] + local dissolve = arg[4] + + self.result_view = MuShi_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, nil) + self.result_view:Show() + ControllerManager.ChangeController(LoddyController) + self:UnmarkSelfTuoguan() end) - + -- 确定开始下一局 成功 _gamectr:AddEventListener(MuShi_GameEvent.OnConfrimToNextGameSucc, function(...) - local arg = {...} + local arg = { ... } local aid = arg[1] local p = self._room:GetPlayerById(aid) if p.seat == self._room.self_player.seat then @@ -988,7 +966,7 @@ function M:EventInit() for _, player in ipairs(self._room.player_list) do local player_head = self._player_info[self:GetPos(player.seat)] player_head:MarkBank(false) - player_head:UpdateFen(-1,0) + player_head:UpdateFen(-1, 0) end self._player_card_info[1]:StarQiangZhuang(1) self.btnstar.visible = fasle @@ -996,7 +974,7 @@ function M:EventInit() end) _gamectr:AddEventListener(MuShi_GameEvent.OnOtherQiangZhuang, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local index = arg[2] if (seat == self._room.self_player.seat) then @@ -1004,18 +982,18 @@ function M:EventInit() end --printlog("iiiiiiiiiiiiiiiiiiii ",seat," ",self:GetPos(seat)) local head_info = self._player_info[self:GetPos(seat)] - head_info:UpdateFen(0,index) + head_info:UpdateFen(0, index) if seat == self._room.self_player.seat then local player1 = self._room:GetPlayerBySeat(seat) - self:PlaySound(player1.self_user.sex,"jiaofen_"..index) + self:PlaySound(player1.self_user.sex, "jiaofen_" .. index) end - printlog("iiiiiiiiiiiiiiiiiiiiii ",index) + printlog("iiiiiiiiiiiiiiiiiiiiii ", index) self.btn_ready1.visible = false end) _gamectr:AddEventListener(MuShi_GameEvent.OnZhuang, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local index = arg[2] local score = arg[3] @@ -1023,37 +1001,36 @@ function M:EventInit() self.currenBank = -1 self.currenBank = seat self.btn_ready1.visible = false - printlog("庄家 客户端相对座位号================",seat," ",self._room.self_player.seat) + printlog("庄家 客户端相对座位号================", seat, " ", self._room.self_player.seat) for _, player in ipairs(self._room.player_list) do local player_head = self._player_info[self:GetPos(player.seat)] player_head:MarkBank(false) end - head_info:UpdateFen(1,score) - -- head_info:MarkBank(true) - self:PlayZhuangEffect() + head_info:UpdateFen(1, score) + -- head_info:MarkBank(true) + self:PlayZhuangEffect() end) _gamectr:AddEventListener(MuShi_GameEvent.OnStarBet, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] - -- printlog("自己座位号===============",self._room.self_player.seat) + -- printlog("自己座位号===============",self._room.self_player.seat) if (seat == self._room.self_player.seat) then self._player_card_info[1]:StarBet(1) local head_info = self._player_info[self:GetPos(seat)] head_info.colKuang = true self.btn_ready1.visible = false end - end) _gamectr:AddEventListener(MuShi_GameEvent.OnBet, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local index = arg[2] local score = arg[3] local head_info = self._player_info[self:GetPos(seat)] - head_info:UpdateFen(2,index) - + head_info:UpdateFen(2, index) + if (seat == self._room.self_player.seat) then self._player_card_info[1]:StarBet(0) local head_info = self._player_info[self:GetPos(seat)] @@ -1063,75 +1040,80 @@ function M:EventInit() end) end -function M:PlayCardTypeVoice(sex,card_type,point) +function M:PlayCardTypeVoice(sex, card_type, point) if card_type == MuShi_CardType.TYPE_SHUANGGUI then - self:PlaySound(sex,"ms_sound_type_10") + self:PlaySound(sex, "ms_sound_type_10") elseif card_type == MuShi_CardType.TYPE_SANGUI then - self:PlaySound(sex,"ms_sound_type_20") + self:PlaySound(sex, "ms_sound_type_20") elseif card_type == MuShi_CardType.TYPE_TIANGONG then - self:PlaySound(sex,"ms_sound_tian_8") + self:PlaySound(sex, "ms_sound_tian_8") elseif card_type == MuShi_CardType.TYPE_DOUBLE_TIANGONG then - self:PlaySound(sex,"ms_sound_tian_9") + self:PlaySound(sex, "ms_sound_tian_9") elseif card_type == MuShi_CardType.TYPE_NORMAL then - self:PlaySound(sex,"ms_sound_point_"..point) + self:PlaySound(sex, "ms_sound_point_" .. point) elseif card_type == MuShi_CardType.TYPE_MUSHI then - self:PlaySound(sex,"ms_sound_point_03") + self:PlaySound(sex, "ms_sound_point_03") elseif card_type == MuShi_CardType.TYPE_TONGHUASHUN then - self:PlaySound(sex,"ms_sound_type_8") + self:PlaySound(sex, "ms_sound_type_8") elseif card_type == MuShi_CardType.TYPE_SANTIAO then - self:PlaySound(sex,"ms_sound_man_type_5") + self:PlaySound(sex, "ms_sound_man_type_5") elseif card_type == MuShi_CardType.TYPE_SHUNZI then - self:PlaySound(sex,"ms_sound_man_type_4") - end + self:PlaySound(sex, "ms_sound_man_type_4") + end end function M:FlyCoinByInfo(info) - self.coinNum = 8 - printlog("庄家信息=======================",self.currenBank," ",self._room.self_player.seat) + self.coinNum = 8 + printlog("庄家信息=======================", self.currenBank, " ", self._room.self_player.seat) if (self.currenBank ~= -1) then local bankHeadInfo = self._player_info[self:GetPos(self.currenBank)] - coroutine.start(function () - for i=1,#info do - local player = info[i] + coroutine.start(function() + for i = 1, #info do + local player = info[i] local head_info = self._player_info[self:GetPos(player.seat)] - if (player.winscore > 0) and player.seat ~=self.currenBank then + if (player.winscore > 0) and player.seat ~= self.currenBank then -- for i=1,self.coinNum do - -- FlyCoin.new(bankHeadInfo._btn_head.displayObject.gameObject.transform.position,head_info._btn_head.displayObject.gameObject.transform.position,self._view) + -- FlyCoin.new(bankHeadInfo._btn_head.displayObject.gameObject.transform.position,head_info._btn_head.displayObject.gameObject.transform.position,self._view) -- coroutine.wait(0.2) -- end - - FlyCoin.new(bankHeadInfo.point.displayObject.gameObject.transform.position,head_info.point.displayObject.gameObject.transform.position,self._view,self.coin) - printlog("playerseatplayerseatplayerseatplayerseatplayerseat111 ",player.seat," ",self._room.self_player.seat) + + FlyCoin.new(bankHeadInfo.point.displayObject.gameObject.transform.position, + head_info.point.displayObject.gameObject.transform.position, self._view, self.coin) + printlog("playerseatplayerseatplayerseatplayerseatplayerseat111 ", player.seat, " ", + self._room.self_player.seat) if self.currenBank == self._room.self_player.seat then - ViewUtil.PlaySound("MuShi_PK","extend/poker/mushi/sound/ms_sound_flychips.mp3") + ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_flychips.mp3") end coroutine.wait(0.2) - elseif(player.winscore < 0 and player.seat ~=self.currenBank) then + elseif (player.winscore < 0 and player.seat ~= self.currenBank) then -- for i=1,self.coinNum do - -- FlyCoin.new(head_info._btn_head.displayObject.gameObject.transform.position,bankHeadInfo._btn_head.displayObject.gameObject.transform.position,self._view) + -- FlyCoin.new(head_info._btn_head.displayObject.gameObject.transform.position,bankHeadInfo._btn_head.displayObject.gameObject.transform.position,self._view) -- coroutine.wait(0.2) -- end - printlog("playerseatplayerseatplayerseatplayerseatplayerseat22222 ",player.seat," ",self._room.self_player.seat) - FlyCoin.new(head_info.point.displayObject.gameObject.transform.position,bankHeadInfo.point.displayObject.gameObject.transform.position,self._view,self.coin) + printlog("playerseatplayerseatplayerseatplayerseatplayerseat22222 ", player.seat, " ", + self._room.self_player.seat) + FlyCoin.new(head_info.point.displayObject.gameObject.transform.position, + bankHeadInfo.point.displayObject.gameObject.transform.position, self._view, self.coin) if self.currenBank == self._room.self_player.seat then - ViewUtil.PlaySound("MuShi_PK","extend/poker/mushi/sound/ms_sound_flychips.mp3") + ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_flychips.mp3") end coroutine.wait(0.2) end end end) else - for i=1,#info do - local player = info[i] + for i = 1, #info do + local player = info[i] local head_info = self._player_info[self:GetPos(player.seat)] - coroutine.start(function () + coroutine.start(function() if (player.winscore > 0) then -- for i=1,self.coinNum do - -- FlyCoin.new(self.btn_ready1.displayObject.gameObject.transform.position,head_info._btn_head.displayObject.gameObject.transform.position,self._view) + -- FlyCoin.new(self.btn_ready1.displayObject.gameObject.transform.position,head_info._btn_head.displayObject.gameObject.transform.position,self._view) -- coroutine.wait(0.02) -- end printlog("playerseatplayerseatplayerseatplayerseatplayerseat333333333333333333333333") - FlyCoin.new(self.btn_ready1.displayObject.gameObject.transform.position,head_info.point.displayObject.gameObject.transform.position,self._view,self.coin) + FlyCoin.new(self.btn_ready1.displayObject.gameObject.transform.position, + head_info.point.displayObject.gameObject.transform.position, self._view, self.coin) if player.seat == self._room.self_player.seat then --printlog("aaaaaaaaaaaaaa33333333333333333333333") ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_flychips.mp3") @@ -1139,11 +1121,12 @@ function M:FlyCoinByInfo(info) coroutine.wait(0.1) elseif (player.winscore < 0) then -- for i=1,self.coinNum do - -- FlyCoin.new(head_info._btn_head.displayObject.gameObject.transform.position,self.btn_ready1.displayObject.gameObject.transform.position,self._view) + -- FlyCoin.new(head_info._btn_head.displayObject.gameObject.transform.position,self.btn_ready1.displayObject.gameObject.transform.position,self._view) -- coroutine.wait(0.02) -- end printlog("playerseatplayerseatplayerseatplayerseatplayerseat4444444444444444444444444444") - FlyCoin.new(head_info.point.displayObject.gameObject.transform.position,self.btn_ready1.displayObject.gameObject.transform.position,self._view,self.coin) + FlyCoin.new(head_info.point.displayObject.gameObject.transform.position, + self.btn_ready1.displayObject.gameObject.transform.position, self._view, self.coin) if player.seat == self._room.self_player.seat then --printlog("aaaaaaaaaaaaaa444444444444444444444444444444444") ViewUtil.PlaySound("MuShi_PK", "extend/poker/mushi/sound/ms_sound_flychips.mp3") @@ -1153,7 +1136,6 @@ function M:FlyCoinByInfo(info) end) end end - end function M:ReConnectForStart() @@ -1164,7 +1146,7 @@ function M:ReConnectForStart() --self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat) --self._state.selectedIndex = 1 --self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat) - + self:UpdateRound(self._room.curren_round) for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] @@ -1190,14 +1172,14 @@ function M:ReConnectForStart() -- end -- head_info:UpdateScore(player.total_score * rt) -- end - + -- head_info:UpdateLineState(player.line_state) -- head_info:UpdatePiao(player.piao) - + -- if player.seat == self._room.self_player.seat then -- player_card_info:InitPoker(player.hand_list) -- else - + -- end end -- gameState = { @@ -1216,57 +1198,57 @@ function M:ReConnectForStart() for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] local head_info = self._player_info[self:GetPos(player.seat)] - if(player.seat == self._room.self_player.seat) and player.isPlaying==true then - if(not player.isQiangZhuang)then + if (player.seat == self._room.self_player.seat) and player.isPlaying == true then + if (not player.isQiangZhuang) then player_card_info:StarQiangZhuang(1) else - head_info:UpdateFen(0,player.qiangZhuangIndex) + head_info:UpdateFen(0, player.qiangZhuangIndex) end else - if(player.isQiangZhuang)then - head_info:UpdateFen(0,player.qiangZhuangIndex) + if (player.isQiangZhuang) then + head_info:UpdateFen(0, player.qiangZhuangIndex) end - end + end end elseif (self._room.roomStatus == gameState.ROOM_STATUS_XIAZHU) then for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] local head_info = self._player_info[self:GetPos(player.seat)] - if(player.seat == self._room.self_player.seat) and player.isPlaying==true then - if(player.isZhuang) then + if (player.seat == self._room.self_player.seat) and player.isPlaying == true then + if (player.isZhuang) then head_info:MarkBank(true) else if (not player.isXiaZhu) then player_card_info:StarBet(1) else - head_info:UpdateFen(2,player.xiaZhuIndex) + head_info:UpdateFen(2, player.xiaZhuIndex) end end else - if(player.isZhuang) then + if (player.isZhuang) then head_info:MarkBank(true) else if (player.isXiaZhu) then - head_info:UpdateFen(2,player.xiaZhuIndex) + head_info:UpdateFen(2, player.xiaZhuIndex) end end - end + end end elseif (self._room.roomStatus == gameState.ROOM_STATUS_BUPAI) then for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] local head_info = self._player_info[self:GetPos(player.seat)] - if(player.seat == self._room.self_player.seat) and player.isPlaying==true then + if (player.seat == self._room.self_player.seat) and player.isPlaying == true then if (not player.isBuPai) then player_card_info:ChangeCtrBuPai(1) end player_card_info:InitPoker2(player.hand_list) - elseif(player.seat == self._room.self_player.seat) and player.isPlaying==false then - - end - if (player.seat ~= self._room.self_player.seat and player.isPlaying==true) then - player_card_info:InitPoker2({0,0}) - end + elseif (player.seat == self._room.self_player.seat) and player.isPlaying == false then + + end + if (player.seat ~= self._room.self_player.seat and player.isPlaying == true) then + player_card_info:InitPoker2({ 0, 0 }) + end end elseif (self._room.roomStatus == gameState.ROOM_STATUS_FINISH) then for _, player in ipairs(self._room.player_list) do @@ -1281,22 +1263,22 @@ function M:ReConnectForStart() head_info._view:GetController('text_color').selectedIndex = 1 head_info._view:GetChild('text_jifen').text = d2ad(player.hp_info.total_hp) end - player_card_info:SetCarType(player.cardType,player.cardPoint) + player_card_info:SetCarType(player.cardType, player.cardPoint) end self.btn_ready1.visible = true self.btn_ready1.onClick:Set(function() self.btn_ready1.visible = fasle local _gamectr = ControllerManager.GetController(GameController) _gamectr:ConformToNextGame() - end) + end) end if self._room.zhuangSeat ~= -1 then self.currenBank = self._room.zhuangSeat - + -- local player_head = self._player_info[self:GetPos(self.currenBank)] - - -- player_head:MarkBank(true) + + -- player_head:MarkBank(true) end if self._room.guiCard then @@ -1311,7 +1293,7 @@ function M:ReconnectForClearing() for _, player in ipairs(self._room.player_list) do local head_info = self._player_info[self:GetPos(player.seat)] local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + --如果是体力值不可负分模式 则显示当前的hp值 if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) @@ -1337,82 +1319,77 @@ function M:ReconnectForClearing() head_info:UpdateLineState(player.line_state) --head_info._view:GetController("Oener").selectedIndex=0 head_info:UpdatePiao(player.piao) - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then end - - - if player.seat == self._room.self_player.seat then + + if player.seat == self._room.self_player.seat then player_card_info:InitPoker(player.hand_list, false) else player_card_info:UpdateHandPoker(player.hand_list, false, true) end if player.out_card_list[1] == 0 then - --player_card_info:SetOutCardInfo(nil, false) else --player_card_info:SetOutCardInfo(player.out_card_list, false) end end - win_seat=self._room.winseat + win_seat = self._room.winseat self._room.winseat = nil - + local remaincards = self._room.remaincards - if self._room.game_status==1 then - - + if self._room.game_status == 1 then -- body coroutine.start(function() coroutine.wait(0.3) - - --self.result_view = MuShi_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat,0,nil) - --self.result_view:Show() - local card_info = self._player_card_info[1] - card_info._view:GetChild("out_card_list").visible=true - end) - if remaincards then - local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards,true) - + --self.result_view = MuShi_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat,0,nil) + --self.result_view:Show() + local card_info = self._player_card_info[1] + card_info._view:GetChild("out_card_list").visible = true + end) + if remaincards then + local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards, true) + -- body local otherpoker_list = self._view:GetChild("otherpoker_list") - + if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end for i = #newremaincards, 1, -1 do coroutine.start(function() coroutine.wait(0.1 * (15 - i)) - + local flow = newremaincards[i] % 10 local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_MuShi", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/"..card_n) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/" .. card_n) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/" .. card_n .. "_1") end card_code_obj:SetScale(0.6, 0.6) poker_item:AddChild(card_code_obj) - -- otherpoker_list:AddChild(poker_item) + -- otherpoker_list:AddChild(poker_item) end) end - end + end end end @@ -1423,7 +1400,6 @@ function M:CreateRankEff() self.rank_view:GetTransition("t0"):Play() end - function M:UpdateRound(round) local total_round = self._room.room_config.Times self._text_round.text = string.format("%d / %d 局", round, total_round) @@ -1468,11 +1444,8 @@ function M:GetSpringSeats(player_info) return seat_list end - - function M:PlaySound(sex, path) - - local sex_path = ViewUtil.Sex_Chat[sex]-- 1 男 2 女 + local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 local sound_path = string.format("extend/poker/mushi/sound/%s/%s.mp3", sex_path, path) ViewUtil.PlaySound("MuShi_PK", sound_path) end @@ -1485,14 +1458,15 @@ function M:ChangeBgmMusic(bgm_index) end ViewUtil.PlayMuisc("MuShi_PK", string.format("extend/poker/mushi/sound/bgm%d.mp3", 1)) end -function M:OnPlayerEnter( ... ) + +function M:OnPlayerEnter(...) --DataManager.CurrenRoom.RoomConfig.people_num --pt(DataManager.CurrenRoom.room_config) --printlog("玩家进入游戏11111111111111111111111111111111111 ") - local arg = {...} + local arg = { ... } local p = arg[1] - for i=1,#self._room.player_list do - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -1501,33 +1475,33 @@ function M:OnPlayerEnter( ... ) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end - if not self._room.self_player.ready and self._room.room_config.people_num ==#self._room.player_list then + if not self._room.self_player.ready and self._room.room_config.people_num == #self._room.player_list then self._ctr_action.selectedIndex = 1 else self._ctr_action.selectedIndex = 0 end - + MainView.OnPlayerEnter(self, ...) end function M:Destroy() - UpdateBeat:Remove(self.OnUpdate,self) + UpdateBeat:Remove(self.OnUpdate, self) for i = 1, #self._room.player_list do local player = self._room.player_list[i] local card_info_i = self._player_card_info[self:GetPos(player.seat)] diff --git a/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerBackView.lua b/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerBackView.lua index 5d106d97..887818ef 100644 --- a/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerBackView.lua +++ b/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerBackView.lua @@ -29,15 +29,15 @@ local MuShi_Record_Event = { local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1'}, - {id = 2, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1'}, - {id = 3, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1'} + { id = 1, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1' }, + { id = 2, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1' }, + { id = 3, url = 'extend/poker/mushi/bg/bg1', thumb = 'ui://Extend_Poker_MuShi/table_bg1' } } --- Create a new function M.new() - setmetatable(M, {__index = PKPlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKPlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'MuShi_PlayBackView' self:init() @@ -51,7 +51,8 @@ function M:InitView(url) end self._gamectr = ControllerManager.GetController(GameController) UIPackage.AddPackage('extend/poker/mushi/ui/Extend_Poker_MuShi') - PKPlayBackView.InitView(self, 'ui://Extend_Poker_MuShi/MuShi_Main_' .. self._room.room_config.people_num, default_bg, bg_config) + PKPlayBackView.InitView(self, 'ui://Extend_Poker_MuShi/MuShi_Main_' .. self._room.room_config.people_num, default_bg, + bg_config) self._tex_round = self._view:GetChild('round') self._player_card_info = {} local _player_card_info = self._player_card_info @@ -63,8 +64,8 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = MuShi_RightPanelView.new(self, rightpanel) + + self._rightPanelView = MuShi_RightPanelView.new(self, rightpanel) rightpanel:GetChild("btn_setting").onClick:Clear() self._player_info = {} @@ -74,7 +75,7 @@ function M:InitView(url) _player_info[i] = PlayerInfoView.new(tem, self) end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -94,7 +95,7 @@ function M:InitView(url) self._eventmap = {} self._cmdmap = {} - + self._cmdmap[MuShi_Record_Event.Evt_alertQiangZhuang] = self.CmdAlertQiangZhuang self._cmdmap[MuShi_Record_Event.Evt_userQiangZhuang] = self.CmdUserQiangZhuang self._cmdmap[MuShi_Record_Event.Evt_zhuangInfo] = self.CmdZhuangInfo @@ -104,24 +105,23 @@ function M:InitView(url) self._cmdmap[MuShi_Record_Event.Evt_playerBuPai] = self.CmdPlayerBuPai self._cmdmap[MuShi_Record_Event.Evt_playerSendCards] = self.CmdPlayerSendCards self._cmdmap[MuShi_Record_Event.Evt_result] = self.CmdResult - + self._cmdmap[MuShi_Record_Event.Evt_OutCard] = self.Wuyong self._cmdmap[MuShi_Record_Event.Evt_Pass] = self.Wuyong self._cmdmap[MuShi_Record_Event.Evt_NewRound] = self.Wuyong self._cmdmap[MuShi_Record_Event.Evt_Result] = self.Wuyong - + self:CuoPai() - end function M:CuoPai() self.cuopai = self._view:GetChild("cuopai") self.cuopai.visible = false - -- print("self.btnY ",self.btnY) + -- -- print("self.btnY ",self.btnY) end function M:Wuyong() - + end function M:NewPlayerPokerInfoView(view, index) @@ -132,7 +132,7 @@ function M:NewPlayerPokerInfoView(view, index) end function M:FillRoomData(data) - --print("hidezhanji 1111") + ---- print("hidezhanji 1111") self._currentStep = 1 local room = DataManager.CurrenRoom local _player_card_info = self._player_card_info @@ -147,11 +147,11 @@ function M:FillRoomData(data) local head_info = self._player_info[self:GetPos(p.seat)] if p.total_hp then - -- print("hidezhanji 2222") - head_info._view:GetChild('zhanji').visible=false + -- -- print("hidezhanji 2222") + head_info._view:GetChild('zhanji').visible = false if room.hpOnOff == 1 or room:checkHpNonnegative() then - head_info._view:GetChild('zhanji').visible=true + head_info._view:GetChild('zhanji').visible = true head_info._view:GetChild('text_jifen').text = d2ad(p.total_hp) end end @@ -161,52 +161,52 @@ function M:FillRoomData(data) -- if p.seat ~= room.self_player.seat then -- card_info:UpdateHandPoker(p.hand_list, false, true) -- end - head_info:UpdatePiao(p.piao) + head_info:UpdatePiao(p.piao) end self:UpdateRound() - + self:GenerateAllStepData(data) self:ShowStep(1) end function M:ShowStep(index) local step = self._step[index] - if step==nil then + if step == nil then return end -- for i = 1, #step.player_card_data do -- local p = self._room:GetPlayerBySeat(i) -- local info = self._player_card_info[self:GetPos(i)] - -- p.hand_list = step.player_card_data[i].hand_list - -- info:InitPoker(p.hand_list, false) + -- p.hand_list = step.player_card_data[i].hand_list + -- info:InitPoker(p.hand_list, false) -- end -- Evt_alertQiangZhuang = 'alertQiangZhuang', --- Evt_userQiangZhuang = 'userQiangZhuang', --- Evt_zhuangInfo = 'zhuangInfo', --- Evt_alertXiaZhu = 'alertXiaZhu', --- Evt_userXiaZhu = 'userXiaZhu', --- Evt_alertBuPai = 'alertBuPai', --- Evt_playerBuPai = 'playerBuPai' + -- Evt_userQiangZhuang = 'userQiangZhuang', + -- Evt_zhuangInfo = 'zhuangInfo', + -- Evt_alertXiaZhu = 'alertXiaZhu', + -- Evt_userXiaZhu = 'userXiaZhu', + -- Evt_alertBuPai = 'alertBuPai', + -- Evt_playerBuPai = 'playerBuPai' if step.cmd == MuShi_Record_Event.Evt_alertQiangZhuang then for _, player in ipairs(self._room.player_list) do local player_head = self._player_info[self:GetPos(player.seat)] player_head:MarkBank(false) - player_head:UpdateFen(-1,0) + player_head:UpdateFen(-1, 0) end self._player_card_info[1]:StarQiangZhuang(1) end if step.cmd == MuShi_Record_Event.Evt_userQiangZhuang then local seat = step.seat - local index = step.index + local index = step.index if (seat == self._room.self_player.seat) then self._player_card_info[1]:StarQiangZhuang(0) - end + end local head_info = self._player_info[self:GetPos(seat)] - head_info:UpdateFen(0,index) + head_info:UpdateFen(0, index) end if step.cmd == MuShi_Record_Event.Evt_zhuangInfo then @@ -217,8 +217,8 @@ function M:ShowStep(index) local player_head = self._player_info[self:GetPos(player.seat)] player_head:MarkBank(false) end - head_info:UpdateFen(1,score) - head_info:MarkBank(true) + head_info:UpdateFen(1, score) + head_info:MarkBank(true) end if step.cmd == MuShi_Record_Event.Evt_alertXiaZhu then @@ -230,10 +230,10 @@ function M:ShowStep(index) if step.cmd == MuShi_Record_Event.Evt_userXiaZhu then local seat = step.seat - local index = step.index + local index = step.index local head_info = self._player_info[self:GetPos(seat)] - head_info:UpdateFen(2,index) - + head_info:UpdateFen(2, index) + if (seat == self._room.self_player.seat) then self._player_card_info[1]:StarBet(0) end @@ -241,7 +241,7 @@ function M:ShowStep(index) if step.cmd == MuShi_Record_Event.Evt_alertBuPai then local seat = step.seat - if(seat == self._room.self_player.seat) then + if (seat == self._room.self_player.seat) then self._player_card_info[1]:ChangeCtrBuPai(1) end end @@ -253,9 +253,9 @@ function M:ShowStep(index) --printlog("补牌================",bupai,card) if (bupai == 1) then local card_info = self._player_card_info[self:GetPos(seat)] - card_info:AddPoker(card,1) + card_info:AddPoker(card, 1) end - if self._room.self_player.seat == seat then + if self._room.self_player.seat == seat then local player_card_info = self._player_card_info[1] player_card_info:ChangeCtrBuPai(0) end @@ -263,7 +263,7 @@ function M:ShowStep(index) if step.cmd == MuShi_Record_Event.Evt_alertBuPai then local seat = step.seat - if(seat == self._room.self_player.seat) then + if (seat == self._room.self_player.seat) then self._player_card_info[1]:ChangeCtrBuPai(1) end end @@ -277,16 +277,15 @@ function M:ShowStep(index) if step.cmd == MuShi_Record_Event.Evt_result then local result = step.result - for i = 1,#result do + for i = 1, #result do local seat = result[i].seat local cardType = result[i].cardType - local cardPoint = result[i].cardPoint - + local cardPoint = result[i].cardPoint + local card_info = self._player_card_info[self:GetPos(seat)] - card_info:SetCarType(cardType,cardPoint) + card_info:SetCarType(cardType, cardPoint) end end - end function M:GenerateAllStepData(data) @@ -314,14 +313,12 @@ function M:GenerateAllStepData(data) end end - - -function M:CmdAlertQiangZhuang(cmd,index) --通知抢庄 +function M:CmdAlertQiangZhuang(cmd, index) --通知抢庄 local data = self:CopyLastStep(index) data.cmd = cmd.cmd end -function M:CmdUserQiangZhuang(cmd,index) --玩家抢庄 +function M:CmdUserQiangZhuang(cmd, index) --玩家抢庄 local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.seat = cmd.data.seat @@ -329,7 +326,7 @@ function M:CmdUserQiangZhuang(cmd,index) --玩家抢庄 data.score = cmd.data.score end -function M:CmdZhuangInfo(cmd,index) --定庄 +function M:CmdZhuangInfo(cmd, index) --定庄 local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.seat = cmd.data.seat @@ -337,47 +334,45 @@ function M:CmdZhuangInfo(cmd,index) --定庄 data.score = cmd.data.score end -function M:CmdAlertXiaZhu(cmd,index) --通知下注 +function M:CmdAlertXiaZhu(cmd, index) --通知下注 local data = self:CopyLastStep(index) data.cmd = cmd.data.cmd data.seat = cmd.data.seat end -function M:CmdUserXiaZhu(cmd,index) --玩家下注 +function M:CmdUserXiaZhu(cmd, index) --玩家下注 local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.seat = cmd.data.seat data.index = cmd.data.index end -function M:CmdAlertBuPai(cmd,index) --通知补牌 +function M:CmdAlertBuPai(cmd, index) --通知补牌 local data = self:CopyLastStep(index) data.cmd = cmd.data.cmd data.seat = cmd.data.seat end -function M:CmdPlayerBuPai(cmd,index) --玩家补牌 +function M:CmdPlayerBuPai(cmd, index) --玩家补牌 local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.bupai = cmd.data.bupai data.card = cmd.data.card end -function M:CmdPlayerSendCards(cmd,index) +function M:CmdPlayerSendCards(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.seat = cmd.data.seat data.cards = cmd.data.cards end -function M:CmdResult(cmd,index) +function M:CmdResult(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.result = cmd.data.result - end - function M:CopyLastStep(index) local step = {} local last_step = self._step[index] diff --git a/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerSelfPokerInfoView.lua index 90a6d5b4..2937df0c 100644 --- a/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/mushi/MuShi_PlayerSelfPokerInfoView.lua @@ -17,7 +17,7 @@ local CardView = { local function NewCardView(card, cardcodenum, cardcodeflower) local self = {} - setmetatable(self, {__index = CardView}) + setmetatable(self, { __index = CardView }) self.btn_card = card self.card_code_number = cardcodenum self.card_code_flower = cardcodeflower @@ -38,8 +38,8 @@ local MuShi_PlayerSelfPokerInfoView = { local M = MuShi_PlayerSelfPokerInfoView function M.new(view, mainView) - setmetatable(M, {__index = MuShi_PlayerPokerInfoView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MuShi_PlayerPokerInfoView }) + local self = setmetatable({}, { __index = M }) self._view = view self._mainView = mainView self.gameCtr = ControllerManager.GetController(GameController) @@ -81,9 +81,9 @@ function M:init() self.carType.visible = false self.carText = self.carType:GetChild("n1") self.carText.text = "" - -- self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_type_10" + -- self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_type_10" --card_niao.icon = "ui://Main_Majiang/202_" .. currentNiaoList[i].card - + self.btnBuPai = self._view:GetChild("bupai") self.btnBu = self._view:GetChild("bubu") self.btnKaiPai = self._view:GetChild("kaipai") @@ -113,8 +113,6 @@ function M:init() self:BtnEvent() end - - function M:BtnEvent() self.btnBuPai.onClick:Set(function() --printlog("点击补牌=================================") @@ -139,55 +137,55 @@ function M:BtnEvent() local _gamectr = ControllerManager.GetController(GameController) _gamectr:SendBuPai(3) end) - - self.btnBank1.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) + + self.btnBank1.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) _gamectr:SendQiangZhuang(0) end) - self.btnBank2.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendQiangZhuang(1) + self.btnBank2.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendQiangZhuang(1) end) - self.btnBank3.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) + self.btnBank3.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) _gamectr:SendQiangZhuang(2) end) - self.btnBank4.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendQiangZhuang(3) + self.btnBank4.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendQiangZhuang(3) end) - self.btnBei1.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) + self.btnBei1.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) _gamectr:SendBet(1) end) - self.btnBei2.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendBet(2) + self.btnBei2.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendBet(2) end) - self.btnBei3.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendBet(3) + self.btnBei3.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendBet(3) end) - self.btnBei4.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendBet(4) + self.btnBei4.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendBet(4) end) - self.btnBei5.onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendBet(5) + self.btnBei5.onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendBet(5) end) end function M:StarQiangZhuang(b) - self.ctr_zhuang.selectedIndex = b + self.ctr_zhuang.selectedIndex = b end function M:StarBet(b) @@ -198,7 +196,7 @@ function M:ChangeCtrBuPai(b) self.ctr_bupai.selectedIndex = b end -function M:InitPoker(pokerList,cardtype,cardopen) +function M:InitPoker(pokerList, cardtype, cardopen) self.cardopen = cardopen for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) @@ -213,7 +211,7 @@ function M:InitPoker(pokerList,cardtype,cardopen) for i = 1, #self.card_list do local card = self.card_list[i] card.index = i - -- self.cards_view:SetChildIndex(card.btn_card, card.index - 1) + -- self.cards_view:SetChildIndex(card.btn_card, card.index - 1) --card.btn_card.xy = self:GetHandCardPos(i, #self.card_list) end @@ -235,11 +233,9 @@ function M:InitPoker2(pokerList) self.card_list[#self.card_list + 1] = card_view end end - - function M:AddPoker(poker) - --print("玩家自己加牌===========================================") + ---- print("玩家自己加牌===========================================") local card_number_code = self:ChangeOneCodeByFrom(poker) local card_flower_code = poker local btn_card = self:CreatPoker(poker, 1, 0) @@ -258,14 +254,14 @@ end function M:GetHandCardPos(index, card_count) local x, y = 0, -18 - local offset = 40 - - x = offset*index + local offset = 40 + + x = offset * index return Vector2.New(x, y) end function M:ChangeOneCodeByFrom(card) - if(card > 500) then + if (card > 500) then return card end local flower = math.floor(card / 100) @@ -283,13 +279,13 @@ function M:ErrorTip(error_text) self.cor_init_poker = nil self.cor_init_poker = coroutine.start( - function() - self.put_error_text.text = error_text - self.ctr_put_error.selectedIndex = 1 - coroutine.wait(2) - self.ctr_put_error.selectedIndex = 0 - end - ) + function() + self.put_error_text.text = error_text + self.ctr_put_error.selectedIndex = 1 + coroutine.wait(2) + self.ctr_put_error.selectedIndex = 0 + end + ) end function M:Clear() @@ -299,7 +295,7 @@ function M:Clear() self.out_card_list = {} self.cards_view:RemoveChildren(0, -1, true) self.carType.visible = false - --self.mask_liangpai:RemoveChildren(0,-1,true) + --self.mask_liangpai:RemoveChildren(0,-1,true) end function M:Destroy() diff --git a/lua_probject/extend_project/extend/poker/runfast/ExtendConfig.lua b/lua_probject/extend_project/extend/poker/runfast/ExtendConfig.lua index 309e63c2..a318fd67 100644 --- a/lua_probject/extend_project/extend/poker/runfast/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/poker/runfast/ExtendConfig.lua @@ -168,7 +168,7 @@ function M:FillRoomData(s2croom) end end else - -- print("aaaaaaaaaaaaaaaa1111111111111111111111111") + -- -- print("aaaaaaaaaaaaaaaa1111111111111111111111111") --pt(s2croom) room.game_status = 1 diff --git a/lua_probject/extend_project/extend/poker/runfast/RunFast_MainView.lua b/lua_probject/extend_project/extend/poker/runfast/RunFast_MainView.lua index 0a87a0c1..6ed54b14 100644 --- a/lua_probject/extend_project/extend/poker/runfast/RunFast_MainView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/RunFast_MainView.lua @@ -12,8 +12,8 @@ local PlayerInfoView = import(".EXPlayerInfoView") local TableBG = import('Game.Data.TableBG') local M = {} function M.new() - setmetatable(M, {__index = PKMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKMainView }) + local self = setmetatable({}, { __index = M }) self.class = "RunFast_MainView" self:init() self._gamectr = ControllerManager.GetController(GameController) @@ -22,18 +22,19 @@ end local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/runfast/bg/bg1', thumb = 'ui://Extend_Poker_RunFastNew/table_bg1'}, - {id = 2, url = 'extend/poker/runfast/bg/bg2', thumb = 'ui://Extend_Poker_RunFastNew/table_bg2'}, - {id = 3, url = 'extend/poker/runfast/bg/bg3', thumb = 'ui://Extend_Poker_RunFastNew/table_bg3'} + { id = 1, url = 'extend/poker/runfast/bg/bg1', thumb = 'ui://Extend_Poker_RunFastNew/table_bg1' }, + { id = 2, url = 'extend/poker/runfast/bg/bg2', thumb = 'ui://Extend_Poker_RunFastNew/table_bg2' }, + { id = 3, url = 'extend/poker/runfast/bg/bg3', thumb = 'ui://Extend_Poker_RunFastNew/table_bg3' } } function M:InitView(url) local room = self._room UIPackage.AddPackage("extend/poker/runfast/ui/Extend_Poker_RunFastNew") - PKMainView.InitView(self, "ui://Extend_Poker_RunFastNew/RunFast_Main_" .. room.room_config.people_num,nil,1,default_bg,bg_config,nil,"ui://Extend_Poker_RunFastNew/SettingWindow1") + PKMainView.InitView(self, "ui://Extend_Poker_RunFastNew/RunFast_Main_" .. room.room_config.people_num, nil, 1, + default_bg, bg_config, nil, "ui://Extend_Poker_RunFastNew/SettingWindow1") local _room = DataManager.CurrenRoom local user_id = DataManager.SelfUser.account_id - local json_data = Utils.LoadLocalFile(user_id.._room.game_id.."pai") + local json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "pai") if json_data == nil then local _gamectr = self._gamectr self._room.pai = 0 @@ -43,7 +44,7 @@ function M:InitView(url) self._room.pai = pai end - json_data = Utils.LoadLocalFile(user_id.._room.game_id.."cardsize") + json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "cardsize") if json_data == nil then local _gamectr = self._gamectr self._room.cardsize = 1 @@ -62,7 +63,7 @@ function M:InitView(url) tem.visible = false end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -74,11 +75,10 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) - for i=1,#self._room.player_list do - - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + + self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -87,30 +87,30 @@ function M:InitView(url) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end - - if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then + + if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then -- body - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text=self._room.score_times .."倍" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = self._room.score_times .. "倍" else - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text="" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = "" end - + self.ctr_state = self._view:GetController("state") self._ctr_action = self._view:GetController("action") self._tex_leftTime = self._view:GetChild("time"):GetChild("title") @@ -118,27 +118,26 @@ function M:InitView(url) self._text_round = self._view:GetChild("round") self.ctr_card_eff = self._view:GetController("card_eff") self._player_card_info = {} - + local _player_card_info = self._player_card_info for i = 1, room.room_config.people_num do local tem = self._view:GetChild("player_card_info_" .. i) _player_card_info[i] = self:NewPlayerCardInfoView(tem, i) end - + local list = room.player_list if not room.self_player.ready then - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else self._ctr_action.selectedIndex = 0 end @@ -152,68 +151,66 @@ function M:InitView(url) self:ReConnectForStart() end else - self._state.selectedIndex = StateType.Palying self:ReconnectForClearing() - end - - self._view:GetChild("btn_back_jiesan").onClick:Set(function () + + self._view:GetChild("btn_back_jiesan").onClick:Set(function() if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) - --local tempdsaf=self._view:GetChild("btn_back_jiesan") - --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) - + --local tempdsaf=self._view:GetChild("btn_back_jiesan") + --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) + --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) + self:ChangeBgmMusic() self:EventInit() - + self._view:GetChild("mask").onClick:Set(function() self:ResetPoker() end) local btn_rule = self._view:GetChild("right_panel"):GetChild("btn_log") self._view:GetChild('info_text'):GetChild('text').text = room.room_config:GetDes() if room.room_config.Leaf == 1 then - if room.room_config.people_num ==2 then + if room.room_config.people_num == 2 then self._view:GetChild('wanfa_text').text = '十五张' .. '二人跑得快' .. room.score_times .. '倍' else self._view:GetChild('wanfa_text').text = '十五张' .. '三人跑得快' .. room.score_times .. '倍' end else if room.room_config.people_num == 2 then - self._view:GetChild('wanfa_text').text = '十六张' .. '二人跑得快' .. room.score_times .. '倍' + self._view:GetChild('wanfa_text').text = '十六张' .. '二人跑得快' .. room.score_times .. '倍' else self._view:GetChild('wanfa_text').text = '十六张' .. '三人跑得快' .. room.score_times .. '倍' end end - if self._view:GetChild("shengyu")~=nil then + if self._view:GetChild("shengyu") ~= nil then -- body - if room.room_config.Leaf==1 then + if room.room_config.Leaf == 1 then -- body - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余15张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余15张" else - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余16张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余16张" end end end -function M:UpdateCard( index ) - self._room.pai=index + +function M:UpdateCard(index) + self._room.pai = index local card_info = self._player_card_info[1] -- for i=1,#self._room.player_list do - -- print(i) + -- -- print(i) -- end card_info:updatePoker() for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + if self._room.curren_turn_seat ~= player.seat then if player.out_card_list[1] == 0 then player_card_info:SetOutCardInfo(nil, true) @@ -222,7 +219,7 @@ function M:UpdateCard( index ) end end end - if self.caozuo==1 then + if self.caozuo == 1 then local ctr_number = self.pass == nil and 2 or 1 local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) local cardType, cardNum, cardLength = self._gamectr:GetCardListInfo(lastCardList) @@ -235,12 +232,12 @@ function M:UpdateCard( index ) m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength,m) + self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength, m) end end function M:UpdateCardSize(index) - self._room.cardsize=index + self._room.cardsize = index local card_info = self._player_card_info[1] card_info:updatePoker() end @@ -254,7 +251,7 @@ end function M:OnPlayerEnter(...) MainView.OnPlayerEnter(self, ...) - local arg = {...} + local arg = { ... } local p = arg[1] local index = self:GetPos(p.seat) local info = self._player_info[index] @@ -269,7 +266,7 @@ function M:OnPlayerEnter(...) end function M:OnPlayerReady(...) - local arg = {...} + local arg = { ... } local p = arg[1] local _room = self._room local _player_info = self._player_info @@ -278,18 +275,18 @@ function M:OnPlayerReady(...) end local info = _player_info[self:GetPos(p.seat)] info:Ready(true) ---local readyNum = 0 ---for i = 1, #_room.player_list do --- local player = _room.player_list[i] --- if player.ready then readyNum = readyNum + 1 end ---end ---if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then --- if self._state.selectedIndex == 2 then --- local _gamectr = ControllerManager.GetController(GameController) --- _gamectr:StartGame() --- end --- --self._ctr_action.selectedIndex = 2 ---end + --local readyNum = 0 + --for i = 1, #_room.player_list do + -- local player = _room.player_list[i] + -- if player.ready then readyNum = readyNum + 1 end + --end + --if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then + -- if self._state.selectedIndex == 2 then + -- local _gamectr = ControllerManager.GetController(GameController) + -- _gamectr:StartGame() + -- end + -- --self._ctr_action.selectedIndex = 2 + --end end function M:OnPlayerLeave(...) @@ -297,89 +294,82 @@ function M:OnPlayerLeave(...) local _room = self._room if not _room.self_player.ready then --self._ctr_action.selectedIndex = 1 - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else self._ctr_action.selectedIndex = 0 end end - function M:EventInit() local _gamectr = ControllerManager.GetController(GameController) MainView.EventInit(self) local _player_info = self._player_info local _player_card_info = self._player_card_info local _room = self._room - - _gamectr:AddEventListener(RunFast_GameEvent.EventXiPai,function( ... ) - - if self.result_view ~= nil then + + _gamectr:AddEventListener(RunFast_GameEvent.EventXiPai, function(...) + if self.result_view ~= nil then self.result_view:Destroy() self.result_view = nil end - - self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + self._player_card_info[1]:HidePiao() + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then self.rank_view:Dispose() self.rank_view = nil end - - local list = _room.player_list + + local list = _room.player_list for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - - end - - - --[[if ( currentPlayer ) then + end + + + --[[if ( currentPlayer ) then self._popEvent = false local xipaiCB=function () self._popEvent = true @@ -396,42 +386,37 @@ function M:EventInit() end--]] - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] - self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - - end - - - if ( currentPlayer2 ) then - --self._popEvent = false - local xipaiCB2=function () - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end - - - - end) - + local arg = { ... } + local currentPlayer1 = arg[1] + local currentPlayer2 = arg[2] + self._popEvent = false + if (currentPlayer1) then + local xipaiCB = function() + self._popEvent = true + end + self:PlayXiPai(xipaiCB) + end + + + if (currentPlayer2) then + --self._popEvent = false + local xipaiCB2 = function() + self._popEvent = true + end + self:PlayXiPai1(xipaiCB2) + end + end) + _gamectr:AddEventListener(RunFast_GameEvent.OnMingCard, function(...) - local arg = {...} + local arg = { ... } local card = arg[1] self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 1 self:PlayCardEff(card) end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnInitCard, function(...) - local arg = {...} + local arg = { ... } local round = arg[1] local cardlist = arg[2] @@ -440,20 +425,20 @@ function M:EventInit() self.result_view:Destroy() self.result_view = nil end - + self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -466,44 +451,40 @@ function M:EventInit() for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - + if p.seat == self._room.self_player.seat then - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body - card_info:InitPoker(cardlist,true,1) + card_info:InitPoker(cardlist, true, 1) else - card_info:InitPoker(cardlist,true) + card_info:InitPoker(cardlist, true) end - else --card_info:UpdateHandPoker(#cardlist,true,false) --todo --card_info:UpdateRemainCard(#cardlist,true) end end end) - - + + -- _gamectr:AddEventListener(RunFast_GameEvent.Oener,function ( ... ) -- local arg = {...} -- local seat = arg[1] @@ -511,11 +492,11 @@ function M:EventInit() -- head_info._view:GetController("Oener").selectedIndex=1 -- end) _gamectr:AddEventListener(RunFast_GameEvent.OnIndexMove, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local isNewBout = arg[2] local index = self:GetPos(seat) - + self.ctr_time.selectedIndex = index -- for i=1,#self._player_info do -- if index==i then @@ -527,16 +508,16 @@ function M:EventInit() -- head_info:MarkBank(false) -- end -- end - + if index == 1 then local card_info = self._player_card_info[index] card_info:SetOutCardInfo(nil, false) - -- if self.MypokerList ~= nil then - -- -- body - -- card_info:Clear() - -- card_info:InitPoker(self.MypokerList, false) - -- self.MypokerList = nil - -- end + -- if self.MypokerList ~= nil then + -- -- body + -- card_info:Clear() + -- card_info:InitPoker(self.MypokerList, false) + -- self.MypokerList = nil + -- end end self._left_time = 20 if self._room.ming_card ~= nil then @@ -548,9 +529,9 @@ function M:EventInit() end end end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnBombScore, function(...) - local arg = {...} + local arg = { ... } local scoreList = arg[1] -- for i = 1, #scoreList do -- local player = self._room:GetPlayerBySeat(i) @@ -560,9 +541,9 @@ function M:EventInit() -- head_info:UpdateScore(player.total_score) -- end end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnPlaySucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] local card_number = arg[2] local cardstype = arg[3] @@ -570,21 +551,19 @@ function M:EventInit() local otherList = arg[5] local length = arg[6] self.ctr_time.selectedIndex = 0 - + local index = self:GetPos(p.seat) - if index==1 then - self.caozuo=0 + if index == 1 then + self.caozuo = 0 end local head_info = self._player_info[index] - if head_info._view:GetChild("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil then -- body -- body - if card_number~=nil then + if card_number ~= nil then -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..card_number.."张" + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. card_number .. "张" end - - end local card_info = self._player_card_info[index] card_info:SetOutCardInfo(p.out_card_list, false, true) @@ -598,7 +577,7 @@ function M:EventInit() card_info:DeleteHandCards(p.out_card_list) else card_info:SetRemainCardNumber(card_number == 1) - --card_info:UpdateHandPoker(card_number,false,false) -- todo + --card_info:UpdateHandPoker(card_number,false,false) -- todo end if self._room.is_new_bout == true then for i = 1, #self._room.player_list do @@ -611,13 +590,13 @@ function M:EventInit() -- card_info:PlayCardTypeEff(cardstype) -- if cardstype~=12 then -- -- body - - + + -- if cardstype==10 and length>=6 then -- -- card_info_i -- local chuan = UIPackage.CreateObject("Extend_Poker_RunFast", "chuan1") -- local card_info_i = self._player_card_info[self:GetPos(p.seat)] - + -- card_info_i._mask_liangpai:AddChild(chuan) -- chuan:GetChild("n0").asMovieClip.playing = true -- ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/sunzi.mp3") @@ -627,7 +606,7 @@ function M:EventInit() -- -- body -- chuan:Dispose() -- end - + -- end) -- else @@ -635,9 +614,8 @@ function M:EventInit() -- end -- end self:_Effect(cardstype, p) - else - if cardstype == 11 and cardstype~=12 then + if cardstype == 11 and cardstype ~= 12 then self:_Effect(cardstype, p) end end @@ -654,41 +632,39 @@ function M:EventInit() self:PlaySound(p.self_user.sex, "card_1") end) end - end) - - - _gamectr:AddEventListener(RunFast_GameEvent.OnPassSuccCheckCard, function(...) - self._popEvent = false - local arg = {...} - local seat = arg[1] + + + _gamectr:AddEventListener(RunFast_GameEvent.OnPassSuccCheckCard, function(...) + self._popEvent = false + local arg = { ... } + local seat = arg[1] local cards = arg[2] --self.MypokerList=cards self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(seat)] - if seat == self._room.self_player.seat then - card_info:ClearCheck() - card_info:InitPoker(cards, false) - - --local player=self._room:GetPlayerBySeat(seat) - --if player.out_card_list[1] == 0 then + if seat == self._room.self_player.seat then + card_info:ClearCheck() + card_info:InitPoker(cards, false) + + --local player=self._room:GetPlayerBySeat(seat) + --if player.out_card_list[1] == 0 then -- player_card_info:SetOutCardInfo(nil, true) --else - --player:SetOutCardInfo({207}, false) - -- end - end - + --player:SetOutCardInfo({207}, false) + -- end + end + self._popEvent = true - end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnPassSucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] - + self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(p.seat)] - + --card_info:SetOutCardInfo(nil, false) if p.seat == self._room.self_player.seat and self.MypokerList ~= nil then -- body @@ -699,31 +675,30 @@ function M:EventInit() card_info:SetOutCardInfo(nil, true) self:PlaySound(p.self_user.sex, "pass_" .. math.random(1, 4)) end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnErrorTip, function(...) - local arg = {...} + local arg = { ... } local error_str = arg[1] self._player_card_info[1]:ErrorTip(error_str) -- self._player_card_info[1]:ResetPoker() end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnPiaoTips, function(...) - local arg = {...} + local arg = { ... } local piao = arg[1] local reload = arg[2] if reload == 0 then - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -745,12 +720,12 @@ function M:EventInit() head_info:UpdatePiao(-1) end end - + self._player_card_info[1]:ShowPiao(piao) end) _gamectr:AddEventListener(RunFast_GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] @@ -758,15 +733,15 @@ function M:EventInit() end) _gamectr:AddEventListener(RunFast_GameEvent.OnOptions, function(...) - local arg = {...} + local arg = { ... } local play = arg[1] local pass = arg[5] local card_type = arg[2] local card_number = arg[3] local card_length = arg[4] local ctr_number = pass == nil and 2 or 1 - self.caozuo=1 --记录是否是自己出牌的阶段 - self.pass=pass + self.caozuo = 1 --记录是否是自己出牌的阶段 + self.pass = pass local m = false local next_seat = self._room.self_player.seat + 1 local card_info = self._player_card_info[1] @@ -784,19 +759,19 @@ function M:EventInit() m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length,m,play,zdts) + self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) end) - -- 托管 - _gamectr:AddEventListener(RunFast_GameEvent.Game_TuoGuan, function(...) - local arg = {...} + -- 托管 + _gamectr:AddEventListener(RunFast_GameEvent.Game_TuoGuan, function(...) + local arg = { ... } local tuoguan = arg[1] local seat = arg[2] - + local tuoguanzhong = self._view:GetChild("tuoguanzhong") local zhezhao = self._view:GetChild("n109") local head_info = self._player_info[self:GetPos(seat)] if (tuoguan == 1) then - if (seat == self._room.self_player.seat ) then + if (seat == self._room.self_player.seat) then tuoguanzhong.visible = true -- tuoguanzhong.sortingOrder = 2 zhezhao.visible = true @@ -806,10 +781,10 @@ function M:EventInit() else head_info._view:GetController("tuoguan").selectedIndex = 1 end - -- if self.ispanguangzhe == true then - -- -- body - -- zhezhao.visible = false - -- end + -- if self.ispanguangzhe == true then + -- -- body + -- zhezhao.visible = false + -- end else if (seat == self._room.self_player.seat) then tuoguanzhong.visible = false @@ -825,14 +800,14 @@ function M:EventInit() end end) _gamectr:AddEventListener(RunFast_GameEvent.OnResult, function(...) - local arg = {...} + local arg = { ... } local over = arg[1] local info = arg[2] local win_seat = arg[3] local remaincards = arg[4] -- local energyTab = arg[5] local otherpoker_list = self._view:GetChild("otherpoker_list") - + if self.MypokerList ~= nil then -- body local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)] @@ -843,12 +818,12 @@ function M:EventInit() if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end - - if remaincards then + + if remaincards then -- body - local newremaincards = _gamectr:ChangeCodeByFrom(remaincards,true) + local newremaincards = _gamectr:ChangeCodeByFrom(remaincards, true) table.sort(remaincards) for i = #newremaincards, 1, -1 do coroutine.start(function() @@ -858,27 +833,27 @@ function M:EventInit() local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj = nil - if DataManager.CurrenRoom.pai==0 then - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if DataManager.CurrenRoom.pai == 0 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n .. + "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/"..card_n) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n) end - else - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/"..card_n.."_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n .. + "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - end if card_code_obj ~= nil then card_code_obj:SetScale(0.6, 0.6) @@ -886,29 +861,24 @@ function M:EventInit() poker_item:AddChild(card_code_obj) otherpoker_list:AddChild(poker_item) end - end - end) - - end - end if self._cor_sound ~= nil then coroutine.stop(self._cor_sound) self._cor_sound = nil end - - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) + + if self.destory_win ~= nil then + coroutine.stop(self.destory_win) end - + self.destory_win = nil self.destory_win = coroutine.start(function() - -- print("11111111111111") + -- -- print("11111111111111") -- coroutine.wait(1) - if self._room.self_player.seat == win_seat then + if self._room.self_player.seat == win_seat then local sprint_seat_list = self:GetSpringSeats(info) if #sprint_seat_list > 0 then local url = "ui://Extend_Poker_RunFastNew/Spring" @@ -919,27 +889,23 @@ function M:EventInit() ViewUtil.PlaySound("RunFastNew_PK", "base/common/sound/win new.mp3") end -- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_RunFastNew/Spring" or "ui://Extend_Poker_RunFastNew/Win_Mine" - - else local beigang = false - if #self:GetSpringSeats(info)>0 then - for i=1,#self:GetSpringSeats(info) do - if self:GetSpringSeats(info)[i]==self._room.self_player.seat then - local url = "ui://Extend_Poker_RunFastNew/spring2" + if #self:GetSpringSeats(info) > 0 then + for i = 1, #self:GetSpringSeats(info) do + if self:GetSpringSeats(info)[i] == self._room.self_player.seat then + local url = "ui://Extend_Poker_RunFastNew/spring2" self.WinItem_view = UIPackage.CreateObjectFromURL(url) self._view:AddChild(self.WinItem_view) self.WinItem_view:Center() self.WinItem_view:GetTransition("t0"):Play() - beigang=true + beigang = true end end - end -- if beigang == false then -- self:CreateRankEff() -- end - end for i = 1, #info do local player = info[i] @@ -965,13 +931,13 @@ function M:EventInit() rt = self._room.score_times end if over == 1 and self._room.hpOnOff == 1 then - head_info:UpdateScore(player.score / 10) --不可负分 + head_info:UpdateScore(player.score / 10) --不可负分 else head_info:UpdateScore(player.score * rt) end card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) end - + if player.seat ~= self._room.self_player.seat then card_info:UpdateHandPoker(player.cards, false, true) @@ -981,14 +947,15 @@ function M:EventInit() self:ChangeBgmMusic(1) -- if over == 0 then if #self:GetSpringSeats(info) > 0 then - -- print("222222222222222222") + -- -- print("222222222222222222") coroutine.wait(1) else - -- print("333333333333333333") + -- -- print("333333333333333333") -- coroutine.wait(2) end - - self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, remaincards) + + self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, + remaincards) self.result_view:Show() if self.WinItem_view ~= nil then self.WinItem_view:Dispose() @@ -1000,50 +967,48 @@ function M:EventInit() end if self._room.self_player.entrust == true then - local btn_confirm = self.result_view._view:GetChild("btn_confirm") + local btn_confirm = self.result_view._view:GetChild("btn_confirm") btn_confirm.onClick:Call() end - -- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow") - -- _actionView.icon = "ui://Common/btn_comfirm" - -- _actionView.onClick:Set(function () - -- --local _gamectr = ControllerManager.GetController(GameController) - -- _gamectr:ConformToNextGame() - -- _actionView:Dispose() - -- end) - -- _actionView.xy = Vector2(900, 625) - -- self._view:AddChild(_actionView) - -- else - -- coroutine.wait(4) - -- self.result_view = RunFast_ResultView.new(self._root_view,info,self._room.room_id) - -- self.result_view:Show() - -- end + -- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow") + -- _actionView.icon = "ui://Common/btn_comfirm" + -- _actionView.onClick:Set(function () + -- --local _gamectr = ControllerManager.GetController(GameController) + -- _gamectr:ConformToNextGame() + -- _actionView:Dispose() + -- end) + -- _actionView.xy = Vector2(900, 625) + -- self._view:AddChild(_actionView) + -- else + -- coroutine.wait(4) + -- self.result_view = RunFast_ResultView.new(self._root_view,info,self._room.room_id) + -- self.result_view:Show() + -- end end) - if over==1 then + if over == 1 then -- body self:UnmarkSelfTuoguan() ControllerManager.ChangeController(LoddyController) - end end) - - _gamectr:AddEventListener(RunFast_GameEvent.OnResultByDissolve, function(...) - - local arg = {...} - local over = arg[1] - local info = arg[2] - local winseat = arg[3] - local dissolve = arg[4] - self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve,nil) - self.result_view:Show() - ControllerManager.ChangeController(LoddyController) - self:UnmarkSelfTuoguan() + _gamectr:AddEventListener(RunFast_GameEvent.OnResultByDissolve, function(...) + local arg = { ... } + local over = arg[1] + local info = arg[2] + local winseat = arg[3] + local dissolve = arg[4] + + self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, nil) + self.result_view:Show() + ControllerManager.ChangeController(LoddyController) + self:UnmarkSelfTuoguan() end) - + -- 确定开始下一局 成功 _gamectr:AddEventListener(RunFast_GameEvent.OnConfrimToNextGameSucc, function(...) - local arg = {...} + local arg = { ... } local aid = arg[1] local p = self._room:GetPlayerById(aid) if p.seat == self._room.self_player.seat then @@ -1062,10 +1027,10 @@ function M:EventInit() local otherpoker_list = self._view:GetChild("otherpoker_list") if otherpoker_list ~= nil then -- body - otherpoker_list.visible=false + otherpoker_list.visible = false otherpoker_list:RemoveChildrenToPool() end - --player_head._view:GetController("Oener").selectedIndex=0 + --player_head._view:GetController("Oener").selectedIndex=0 end end local player_info = self._player_info[self:GetPos(p.seat)] @@ -1074,12 +1039,11 @@ function M:EventInit() end function M:ReConnectForStart() - local _gamectr = ControllerManager.GetController(GameController) self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat) self._state.selectedIndex = 1 self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat) - + self:UpdateRound(self._room.curren_round) for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] @@ -1105,40 +1069,33 @@ function M:ReConnectForStart() end head_info:UpdateScore(player.total_score * rt) end - + head_info:UpdateLineState(player.line_state) head_info:UpdatePiao(player.piao) - - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - - if self._room.room_config.showlength==1 then + + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" end if player.seat == self._room.self_player.seat then - if player.open ~= nil and player.open == 0 and self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if player.open ~= nil and player.open == 0 and self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = player.hand_list player_card_info:InitPoker(player.hand_list, false, 1) - else - player_card_info:InitPoker(player.hand_list, false) end - else - player_card_info:SetRemainCardNumber(player.hand_count == 1) if player.hand_count == 1 then self.bgm_index = 2 @@ -1164,7 +1121,7 @@ function M:ReconnectForClearing() for _, player in ipairs(self._room.player_list) do local head_info = self._player_info[self:GetPos(player.seat)] local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + --如果是体力值不可负分模式 则显示当前的hp值 if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) @@ -1190,93 +1147,88 @@ function M:ReconnectForClearing() head_info:UpdateLineState(player.line_state) --head_info._view:GetController("Oener").selectedIndex=0 head_info:UpdatePiao(player.piao) - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then - -- body - head_info._view:GetController("shengyu").selectedIndex=1 - else - head_info._view:GetController("shengyu").selectedIndex=0 - end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - end - - - if player.seat == self._room.self_player.seat then + if self._room.room_config.showlength == 1 then + -- body + head_info._view:GetController("shengyu").selectedIndex = 1 + else + head_info._view:GetController("shengyu").selectedIndex = 0 + end + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" + end + + + if player.seat == self._room.self_player.seat then player_card_info:InitPoker(player.hand_list, false) else player_card_info:UpdateHandPoker(player.hand_list, false, true) end if player.out_card_list[1] == 0 then - player_card_info:SetOutCardInfo(nil, false) else player_card_info:SetOutCardInfo(player.out_card_list, false) end end - win_seat=self._room.winseat + win_seat = self._room.winseat self._room.winseat = nil - + local remaincards = self._room.remaincards - if self._room.game_status==1 then - - + if self._room.game_status == 1 then -- body coroutine.start(function() coroutine.wait(0.3) - - self.result_view = RunFast_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat,0,remaincards) - self.result_view:Show() - local card_info = self._player_card_info[1] - card_info._view:GetChild("out_card_list").visible=true - end) - if remaincards then - local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards,true) - + self.result_view = RunFast_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, + win_seat, 0, remaincards) + self.result_view:Show() + local card_info = self._player_card_info[1] + card_info._view:GetChild("out_card_list").visible = true + end) + if remaincards then + local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards, true) + -- body local otherpoker_list = self._view:GetChild("otherpoker_list") - + if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end for i = #newremaincards, 1, -1 do coroutine.start(function() coroutine.wait(0.1 * (15 - i)) - + local flow = newremaincards[i] % 10 local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/"..card_n) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n .. "_1") end card_code_obj:SetScale(0.6, 0.6) poker_item:AddChild(card_code_obj) otherpoker_list:AddChild(poker_item) end) end - end + end end end @@ -1287,11 +1239,11 @@ function M:CreateRankEff() self.rank_view:GetTransition("t0"):Play() end -function M:_Effect( type1 ,player) +function M:_Effect(type1, player) -- body - - if type1 < 7 and type1 ~= 4 and type1 ~= 5 then - return + + if type1 < 7 and type1 ~= 4 and type1 ~= 5 then + return end local eff_code = 0 if type1 == 10 then @@ -1309,35 +1261,35 @@ function M:_Effect( type1 ,player) end local info = self._player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai - local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff_"..eff_code) + local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff_" .. eff_code) -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff2_1") effect.touchable = false effect:GetTransition("t0"):Play() -- effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - if eff_code==3 then + if eff_code == 3 then self._view:AddChild(effect) else pNode:AddChild(effect) end - - if eff_code==1 then + + if eff_code == 1 then self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff_feiji") self._view:AddChild(self.eff_feiji) self.eff_feiji:Center() self.eff_feiji:GetTransition("t0"):Play() end - if eff_code==3 then + if eff_code == 3 then effect:Center() else - if self:GetPos(player.seat)== 1 then - effect.x,effect.y = 0,24 + if self:GetPos(player.seat) == 1 then + effect.x, effect.y = 0, 24 else - effect.x,effect.y = 24,67 + effect.x, effect.y = 24, 67 end end - - + + -- effect:Center() -- if eff_code ==3 then -- coroutine.start(function() @@ -1347,53 +1299,54 @@ function M:_Effect( type1 ,player) -- else coroutine.start(function() coroutine.wait(1) - if self.eff_feiji~=nil then + if self.eff_feiji ~= nil then self.eff_feiji:Dispose() end effect:Dispose() end) -- end end + -- function M:_Effect(type1, player) - -- if type1 < 7 and type1 ~= 4 then return end - -- local eff_code = 0 - -- if type1 == 10 then --顺子 - -- eff_code = 2 - -- elseif type1 == 11 then --炸 - -- eff_code = 3 - -- elseif type1 == 4 then --连对 - -- eff_code = 4 - -- else - -- eff_code = 6 - -- end - -- local info = self._player_card_info[self:GetPos(player.seat)] - -- local pNode = info._mask_liangpai - -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/MovieClip" .. eff_code) - - -- effect.touchable = false - - -- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - -- pNode:AddChild(effect) - -- if type1 == 10 then --顺子 - -- effect.x, effect.y = -400, -200 - -- elseif type1 == 11 then --炸 - -- effect.x, effect.y = -80, -225 - -- elseif type1 == 4 then --连对 - -- effect.x, effect.y = -400, -200 - -- else - -- effect.x, effect.y = -157, -140 - -- end - -- coroutine.start(function() - -- if type1== 10 or type1== 11 or type1== 4 then - -- -- body - -- coroutine.wait(2) - -- effect:Dispose() - -- else - -- coroutine.wait(1.2) - -- effect:Dispose() - -- end - - -- end) +-- if type1 < 7 and type1 ~= 4 then return end +-- local eff_code = 0 +-- if type1 == 10 then --顺子 +-- eff_code = 2 +-- elseif type1 == 11 then --炸 +-- eff_code = 3 +-- elseif type1 == 4 then --连对 +-- eff_code = 4 +-- else +-- eff_code = 6 +-- end +-- local info = self._player_card_info[self:GetPos(player.seat)] +-- local pNode = info._mask_liangpai +-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/MovieClip" .. eff_code) + +-- effect.touchable = false + +-- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) +-- pNode:AddChild(effect) +-- if type1 == 10 then --顺子 +-- effect.x, effect.y = -400, -200 +-- elseif type1 == 11 then --炸 +-- effect.x, effect.y = -80, -225 +-- elseif type1 == 4 then --连对 +-- effect.x, effect.y = -400, -200 +-- else +-- effect.x, effect.y = -157, -140 +-- end +-- coroutine.start(function() +-- if type1== 10 or type1== 11 or type1== 4 then +-- -- body +-- coroutine.wait(2) +-- effect:Dispose() +-- else +-- coroutine.wait(1.2) +-- effect:Dispose() +-- end + +-- end) -- if eff_code ==3 then -- coroutine.start(function() -- coroutine.wait(1) @@ -1467,17 +1420,17 @@ function M:PlayCardEff(card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/"..card) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") end - if card_code_obj then - card_code_obj:SetScale(1, 1) - poker_obj:AddChild(card_code_obj) - card_code_obj.visible = true - end - + if card_code_obj then + card_code_obj:SetScale(1, 1) + poker_obj:AddChild(card_code_obj) + card_code_obj.visible = true + end + self.tween = TweenUtils.TweenFloat(0, 2340, cor_time, function(x) poker_back.rotationY = x poker_obj.rotationY = -180 + x @@ -1493,7 +1446,6 @@ function M:PlayCardEff(card) coroutine.wait(1) self._popEvent = true end) - end function M:ResetPoker() @@ -1504,8 +1456,7 @@ function M:ResetPoker() end function M:PlaySound(sex, path) - - local sex_path = ViewUtil.Sex_Chat[sex]-- 1 男 2 女 + local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 local sound_path = string.format("extend/poker/runfast/sound/%s/%s.mp3", sex_path, path) ViewUtil.PlaySound("RunFastNew_PK", sound_path) end @@ -1518,11 +1469,12 @@ function M:ChangeBgmMusic(bgm_index) end ViewUtil.PlayMuisc("RunFastNew_PK", string.format("extend/poker/runfast/sound/bgm%d.mp3", 1)) end -function M:OnPlayerEnter( ... ) - local arg = {...} + +function M:OnPlayerEnter(...) + local arg = { ... } local p = arg[1] - for i=1,#self._room.player_list do - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -1531,26 +1483,26 @@ function M:OnPlayerEnter( ... ) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end -- if p ~= self._room.self_player and self._room.room_config.people_num <= 4 and self._room.room_config.people_num >= 3 and self._gamectr:CheckGPS() then -- if self.distance_view then -- self.distance_view:Destroy() - -- end + -- end -- self.distance_view = PlayerDistanceView.new(true) -- self.distance_view:Show() -- end diff --git a/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerBackView.lua b/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerBackView.lua index 0ca91630..4c4597b5 100644 --- a/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerBackView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerBackView.lua @@ -20,15 +20,15 @@ local RunFast_Record_Event = { local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/runfast/bg/bg1', thumb = 'ui://Extend_Poker_RunFastNew/table_bg1'}, - {id = 2, url = 'extend/poker/runfast/bg/bg2', thumb = 'ui://Extend_Poker_RunFastNew/table_bg2'}, - {id = 3, url = 'extend/poker/runfast/bg/bg3', thumb = 'ui://Extend_Poker_RunFastNew/table_bg3'} + { id = 1, url = 'extend/poker/runfast/bg/bg1', thumb = 'ui://Extend_Poker_RunFastNew/table_bg1' }, + { id = 2, url = 'extend/poker/runfast/bg/bg2', thumb = 'ui://Extend_Poker_RunFastNew/table_bg2' }, + { id = 3, url = 'extend/poker/runfast/bg/bg3', thumb = 'ui://Extend_Poker_RunFastNew/table_bg3' } } --- Create a new function M.new() - setmetatable(M, {__index = PKPlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKPlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'RunFast_PlayBackView' self:init() @@ -42,7 +42,8 @@ function M:InitView(url) end self._gamectr = ControllerManager.GetController(GameController) UIPackage.AddPackage('extend/poker/runfast/ui/Extend_Poker_RunFastNew') - PKPlayBackView.InitView(self, 'ui://Extend_Poker_RunFastNew/RunFast_Main_' .. self._room.room_config.people_num, default_bg, bg_config) + PKPlayBackView.InitView(self, 'ui://Extend_Poker_RunFastNew/RunFast_Main_' .. self._room.room_config.people_num, + default_bg, bg_config) self._tex_round = self._view:GetChild('round') self._player_card_info = {} local _player_card_info = self._player_card_info @@ -54,8 +55,8 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) + + self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) rightpanel:GetChild("btn_setting").onClick:Clear() self._player_info = {} @@ -65,7 +66,7 @@ function M:InitView(url) _player_info[i] = PlayerInfoView.new(tem, self) end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -94,7 +95,7 @@ function M:NewPlayerPokerInfoView(view, index) end function M:FillRoomData(data) - print("hidezhanji 1111") + -- print("hidezhanji 1111") self._currentStep = 1 local room = DataManager.CurrenRoom local _player_card_info = self._player_card_info @@ -109,12 +110,12 @@ function M:FillRoomData(data) local head_info = self._player_info[self:GetPos(p.seat)] if p.total_hp then - print("hidezhanji 2222") + -- print("hidezhanji 2222") - head_info._view:GetChild('zhanji').visible=false + head_info._view:GetChild('zhanji').visible = false if room.hpOnOff == 1 or room:checkHpNonnegative() then - head_info._view:GetChild('zhanji').visible=true + head_info._view:GetChild('zhanji').visible = true head_info._view:GetChild('text_jifen').text = d2ad(p.total_hp) end end @@ -125,18 +126,17 @@ function M:FillRoomData(data) card_info:UpdateHandPoker(p.hand_list, false, true) end head_info:UpdatePiao(p.piao) - end self:UpdateRound() - + self:GenerateAllStepData(data) self:ShowStep(1) end function M:ShowStep(index) local step = self._step[index] - if step==nil then + if step == nil then return end for i = 1, #step.player_card_data do @@ -146,13 +146,12 @@ function M:ShowStep(index) p.hand_list = step.player_card_data[i].hand_list p.out_card_list = step.player_card_data[i].out_card_list p.hand_left_count = #p.hand_list - + if p.seat ~= self._room.self_player.seat then info:UpdateHandPoker(p.hand_list, false, true) else info:InitPoker(p.hand_list, false) end - end if step.cmd == RunFast_Record_Event.Evt_OutCard then @@ -194,7 +193,8 @@ function M:ShowStep(index) end if step.cmd == RunFast_Record_Event.Evt_Result then local Result = step.Result - self.result_view = RunFast_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, Result.winseat, 0, Result.remaincards) + self.result_view = RunFast_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, + Result.winseat, 0, Result.remaincards) local num = self._view:GetChildIndex(self._view:GetChild("panel_record")) self._view:AddChildAt(self.result_view._view, num) else @@ -257,6 +257,7 @@ function M:CmdPass(cmd, index) data.cmd = cmd.cmd data.current_out_seat = cmd.seat end + function M:Cmdresult(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd diff --git a/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua index 3f54e00c..0aef9d77 100644 --- a/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua @@ -88,7 +88,7 @@ function M:InitPoker(pokerList, isPlayAni, open) -- self.zhizhanplay=0 -- self.zhizhanzdts=0 local cs = 1.25 - print("==========================DataManager.CurrenRoom.cardsize", DataManager.CurrenRoom.cardsize) + -- print("==========================DataManager.CurrenRoom.cardsize", DataManager.CurrenRoom.cardsize) if DataManager.CurrenRoom.cardsize == 0 then cs = 2 elseif DataManager.CurrenRoom.cardsize == 1 then @@ -100,7 +100,7 @@ function M:InitPoker(pokerList, isPlayAni, open) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end - -- print(vardump(self.card_list)) + -- -- print(vardump(self.card_list)) self.cor_init_poker = nil self.card_list = {} @@ -281,7 +281,7 @@ function M:AddCardMoveEvent(card) if card.btn_card.touchable == true then send_card[#send_card + 1] = card self:SetBtnCardColor(card, 1) - --print(vardump(card)) + ---- print(vardump(card)) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and @@ -462,7 +462,7 @@ function M:TouchMoving(context) end end end - --print(vardump(send_card1)) + ---- print(vardump(send_card1)) -- local send_card = {} -- self.send_card = {} -- for i = 1, #self.card_list do diff --git a/lua_probject/extend_project/extend/poker/runfast/RunFast_RightPanelView.lua b/lua_probject/extend_project/extend/poker/runfast/RunFast_RightPanelView.lua index 6a842d42..213713c6 100644 --- a/lua_probject/extend_project/extend/poker/runfast/RunFast_RightPanelView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/RunFast_RightPanelView.lua @@ -1,7 +1,7 @@ local MainRightPanelView = require("Game.View.MainRightPanelView") local RunFast_RightPanelView = {} local M = RunFast_RightPanelView -local function __init(self,mainView,view) +local function __init(self, mainView, view) local right_panel = view local btn_setting = right_panel:GetChild("btn_setting") @@ -22,17 +22,17 @@ local function __init(self,mainView,view) end end) else - print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) + -- print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) if mainView.dismiss_room_cd_time > 0 then GameApplication.Instance:ShowTips("您还处于解散冷却时间当中,请稍后重试!") else - _gamectr:AskDismissRoom() + _gamectr:AskDismissRoom() end end end) end) - self._tex_data = right_panel:GetChild("tex_data") + self._tex_data = right_panel:GetChild("tex_data") self._tex_time = right_panel:GetChild("tex_time") self._pb_batteryLevel = right_panel:GetChild("pb_batteryLevel") self._xinhao = right_panel:GetController("xinhao") @@ -50,21 +50,22 @@ local function __init(self,mainView,view) self._total_time = 0 self:__UpdateTime() - + -- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true) -- self._timer:Start() end -function RunFast_RightPanelView.new(mainView,view) - setmetatable(M, {__index = MainRightPanelView}) - local self = setmetatable({}, {__index = M}) - self.class = "RunFast_RightPanelView" - __init(self,mainView,view) +function RunFast_RightPanelView.new(mainView, view) + setmetatable(M, { __index = MainRightPanelView }) + local self = setmetatable({}, { __index = M }) + self.class = "RunFast_RightPanelView" + __init(self, mainView, view) return self end + function M:__UpdateTime() self._tex_data.text = os.date("%Y-%m-%d") self._tex_time.text = os.date("%H:%M") - if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then + if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then self._pb_batteryLevel.value = GameApplication.Instance:GetBatteryLevel() end @@ -74,7 +75,7 @@ function M:__UpdateTime() local ping = _client:getAveragePingTime() if not ping then return end ping = math.floor(ping / 2) - if ping > 300 then ping =300 end + if ping > 300 then ping = 300 end if ping <= 100 then self.ctr_xh.selectedIndex = 0 elseif ping <= 300 then @@ -85,4 +86,4 @@ function M:__UpdateTime() self._tex_ping.text = ping .. "ms" end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/poker/sanqianfen/ExtendConfig.lua b/lua_probject/extend_project/extend/poker/sanqianfen/ExtendConfig.lua index d8877a32..010a00cf 100644 --- a/lua_probject/extend_project/extend/poker/sanqianfen/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/poker/sanqianfen/ExtendConfig.lua @@ -18,8 +18,8 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) self.class = "ExtendConfig" self.extend_id = 14 self._viewMap = {} @@ -38,13 +38,13 @@ function M:UnAssets() UIPackage.RemovePackage("extend/poker/sanqianfen/ui/Extend_Poker_SanQianFenNew") ResourcesManager.UnLoadGroup("RunFase_PK") end - + local _gameInfo = nil function M:GetGameInfo() -if not _gameInfo then - _gameInfo = EXGameInfo.new() -end -return _gameInfo + if not _gameInfo then + _gameInfo = EXGameInfo.new() + end + return _gameInfo end local _ctr_game = nil @@ -68,7 +68,7 @@ function M:GetIconUrl() -- end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = SanQianFen_RoomConfig.new(_config) end @@ -81,19 +81,19 @@ function M:FillRoomData(s2croom) local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - - room.xipaiScore=_tableInfo["xipai_score"] + + room.xipaiScore = _tableInfo["xipai_score"] local _config = _tableInfo["config"] room.room_config = SanQianFen_RoomConfig.new(_config) room.curren_round = _tableInfo["round"] - if room.curren_round == 0 and reload then - room.curren_round = 1 + if room.curren_round == 0 and reload then + room.curren_round = 1 end local playerList = _tableInfo["playerData"] - for i = 1,#playerList do + for i = 1, #playerList do local _jp = playerList[i] local p = SanQianFen_Player.new() @@ -110,10 +110,9 @@ function M:FillRoomData(s2croom) u.account_id = pid p.self_user = u u.nick_name = _jp["nick"] - + u.head_url = _jp["portrait"] u.sex = _jp["sex"] - end p.self_user.location = Location.new(_jp["pos"] or "") p.self_user.host_ip = _jp["ip"] @@ -135,10 +134,9 @@ function M:FillRoomData(s2croom) room.owner_id = owner room.game_status = 0 if reload then - local reloadInfo = s2croom["reloadInfo"] - - + + local playing = reloadInfo["playing"] @@ -149,20 +147,18 @@ function M:FillRoomData(s2croom) room.curkNum = reloadInfo["curkNum"] local info_list = reloadInfo["info_list"] if playing == true then - - room.CurnrenState = StateType.Palying - room.game_status=1 - + room.game_status = 1 + for i = 1, #info_list do local p = room:GetPlayerById(info_list[i]["playerid"]) if p == room.self_player then p.hand_list = reloadInfo["hand_card"] - p.open= reloadInfo["open"] + p.open = reloadInfo["open"] end - + p.hand_count = info_list[i]["card_size"] p.piao = info_list[i]["piao"] p.handCards = info_list[i]["handCards"] @@ -174,17 +170,17 @@ function M:FillRoomData(s2croom) local last_outcard = info_list[i]["last_outcard"] if last_outcard ~= nil and last_outcard[1] ~= 0 then - local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list,true) - local card_type,number,length,plan_three_count = _ctr_game:GetCardListInfo(out_card_list) - p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list,card_type,number,plan_three_count) + local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list, true) + local card_type, number, length, plan_three_count = _ctr_game:GetCardListInfo(out_card_list) + p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list, card_type, number, plan_three_count) else - p.out_card_list = {0} + p.out_card_list = { 0 } end end else - -- print("aaaaaaaaaaaaaaaa1111111111111111111111111") + -- -- print("aaaaaaaaaaaaaaaa1111111111111111111111111") --pt(s2croom) - room.game_status=1 + room.game_status = 1 room.CurnrenState = StateType.PalyingWait @@ -194,43 +190,40 @@ function M:FillRoomData(s2croom) for i = 1, #info_list do local playerData = info_list[i] local p = room:GetPlayerById(playerData["playerid"]) - + p.ready = playerData["certainseat"] == 1 and true or false local last_outcard = info_list[i]["last_outcard"] if last_outcard ~= nil and last_outcard[1] ~= 0 then - - local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list,true) - local card_type,number,length,plan_three_count = _ctr_game:GetCardListInfo(out_card_list) - p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list,card_type,number,plan_three_count) + local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list, true) + local card_type, number, length, plan_three_count = _ctr_game:GetCardListInfo(out_card_list) + p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list, card_type, number, plan_three_count) else - p.out_card_list = {0} + p.out_card_list = { 0 } end - + p.hand_list = info_list[i]["cards"] p.winscore = info_list[i]["winscore"] p.piao = info_list[i]["piao"] p.hand_count = info_list[i]["card_size"] - p.thisboomnum=info_list[i]["thisboomnum"] - p.open= info_list[i]["open"] - p.cur510kFen=info_list[i]["cur510kFen"] - p.ju510kFen=info_list[i]["ju510kFen"] - p.juXiFen=info_list[i]["juXiFen"] - p.curXiFen=info_list[i]["curXiFen"] - p.jiangli=info_list[i]["jiangli"] - p.leftCardFen=info_list[i]["leftCardFen"] + p.thisboomnum = info_list[i]["thisboomnum"] + p.open = info_list[i]["open"] + p.cur510kFen = info_list[i]["cur510kFen"] + p.ju510kFen = info_list[i]["ju510kFen"] + p.juXiFen = info_list[i]["juXiFen"] + p.curXiFen = info_list[i]["curXiFen"] + p.jiangli = info_list[i]["jiangli"] + p.leftCardFen = info_list[i]["leftCardFen"] p.handCards = info_list[i]["handCards"] p.outCards = info_list[i]["outCards"] - end + end end else room.CurnrenState = StateType.Ready end end - - function M:FillPlayBackData(pd_data) local room = DataManager.CurrenRoom local _tableInfo = pd_data["info"] @@ -245,7 +238,7 @@ function M:FillPlayBackData(pd_data) room.curren_turn_seat = active_seat room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = SanQianFen_Player.new() p.seat = _jp["seat"] @@ -258,8 +251,8 @@ function M:FillPlayBackData(pd_data) u.account_id = pid p.self_user = u u.nick_name = _jp["nick"] - - + + u.head_url = _jp["portrait"] u.sex = _jp["sex"] -- end @@ -269,7 +262,7 @@ function M:FillPlayBackData(pd_data) p.hand_count = #_hand_card p.total_score = _jp["score"] p.piao = _jp["piao"] - p.open= _jp["open"] + p.open = _jp["open"] p.hp_info = _jp["hp_info"] p.cur510kFen = _jp["cur510kFen"] p.curXiFen = _jp["curXiFen"] @@ -284,4 +277,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_MainView.lua b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_MainView.lua index c68109d0..15a0dffc 100644 --- a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_MainView.lua +++ b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_MainView.lua @@ -12,8 +12,8 @@ local PlayerInfoView = import(".EXPlayerInfoView") local TableBG = import('Game.Data.TableBG') local M = {} function M.new() - setmetatable(M, {__index = PKMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKMainView }) + local self = setmetatable({}, { __index = M }) self.class = "SanQianFen_MainView" --self._full = true self:init() @@ -23,18 +23,19 @@ end local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/sanqianfen/bg/bg1', thumb = 'ui://Extend_Poker_SanQianFen/table_bg1'}, - {id = 2, url = 'extend/poker/sanqianfen/bg/bg2', thumb = 'ui://Extend_Poker_SanQianFen/table_bg2'}, - {id = 3, url = 'extend/poker/sanqianfen/bg/bg3', thumb = 'ui://Extend_Poker_SanQianFen/table_bg3'} + { id = 1, url = 'extend/poker/sanqianfen/bg/bg1', thumb = 'ui://Extend_Poker_SanQianFen/table_bg1' }, + { id = 2, url = 'extend/poker/sanqianfen/bg/bg2', thumb = 'ui://Extend_Poker_SanQianFen/table_bg2' }, + { id = 3, url = 'extend/poker/sanqianfen/bg/bg3', thumb = 'ui://Extend_Poker_SanQianFen/table_bg3' } } function M:InitView(url) local room = self._room UIPackage.AddPackage("extend/poker/sanqianfen/ui/Extend_Poker_SanQianFen") - PKMainView.InitView(self, "ui://Extend_Poker_SanQianFen/SanQianFen_Main_" .. room.room_config.people_num,nil,1,default_bg,bg_config,nil,"ui://Extend_Poker_SanQianFen/SettingWindow1") + PKMainView.InitView(self, "ui://Extend_Poker_SanQianFen/SanQianFen_Main_" .. room.room_config.people_num, nil, 1, + default_bg, bg_config, nil, "ui://Extend_Poker_SanQianFen/SettingWindow1") local _room = DataManager.CurrenRoom local user_id = DataManager.SelfUser.account_id - local json_data = Utils.LoadLocalFile(user_id.._room.game_id.."pai") + local json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "pai") if json_data == nil then local _gamectr = self._gamectr self._room.pai = 0 @@ -44,7 +45,7 @@ function M:InitView(url) self._room.pai = pai end - json_data = Utils.LoadLocalFile(user_id.._room.game_id.."cardsize") + json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "cardsize") if json_data == nil then local _gamectr = self._gamectr self._room.cardsize = 1 @@ -67,17 +68,17 @@ function M:InitView(url) -- zong:GetChild('xi_ju').text = "0" -- zong:GetChild('xi_zong').text = "0" _player_info[i]._view:GetChild('510score').text = "0" - local c1 = view1_510k:GetChild('play_name'..i) - local c2 = view1_510k:GetChild('play_lishi'..i) - local c3 = view1_510k:GetChild('play_ju'..i) - local c4 = view1_510k:GetChild('play_zong'..i) - _player_info[i]:InitScoreComp(c1,c3,c2,nil,c4) + local c1 = view1_510k:GetChild('play_name' .. i) + local c2 = view1_510k:GetChild('play_lishi' .. i) + local c3 = view1_510k:GetChild('play_ju' .. i) + local c4 = view1_510k:GetChild('play_zong' .. i) + _player_info[i]:InitScoreComp(c1, c3, c2, nil, c4) tem.visible = false end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -89,11 +90,10 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = SanQianFen_RightPanelView.new(self, rightpanel) - for i=1,#self._room.player_list do - - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + + self._rightPanelView = SanQianFen_RightPanelView.new(self, rightpanel) + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -102,30 +102,30 @@ function M:InitView(url) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end - - if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then + + if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then -- body - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text=self._room.score_times .."倍" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = self._room.score_times .. "倍" else - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text="" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = "" end - -- self.AllScore = self._view:GetChild("AllScore") + -- self.AllScore = self._view:GetChild("AllScore") --self.AllScore.text = "总分:".."0" local view_510k = self._view:GetChild("10k5") local ctr_peple = view_510k:GetController("c1") @@ -156,31 +156,30 @@ function M:InitView(url) -- local head_info = self._player_info[1] -- head_info.ctr_shangyou.selectedIndex = 1 -- end - + -- ) - - + + local _player_card_info = self._player_card_info for i = 1, room.room_config.people_num do local tem = self._view:GetChild("player_card_info_" .. i) _player_card_info[i] = self:NewPlayerCardInfoView(tem, i) end - + local list = room.player_list if not room.self_player.ready then - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else self._ctr_action.selectedIndex = 0 end @@ -194,90 +193,86 @@ function M:InitView(url) self:ReConnectForStart() end else - self._state.selectedIndex = StateType.Palying self:ReconnectForClearing() - end - - self._view:GetChild("btn_back_jiesan").onClick:Set(function () + + self._view:GetChild("btn_back_jiesan").onClick:Set(function() if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) - --local tempdsaf=self._view:GetChild("btn_back_jiesan") - --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) - + --local tempdsaf=self._view:GetChild("btn_back_jiesan") + --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) + --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) + self:ChangeBgmMusic() self:EventInit() - + self._view:GetChild("mask").onClick:Set(function() self:ResetPoker() end) local btn_rule = self._view:GetChild("right_panel"):GetChild("btn_log") --self._view:GetChild('info_text'):GetChild('text').text = room.room_config:GetDes() if room.room_config.Leaf == 1 then - if room.room_config.people_num ==2 then + if room.room_config.people_num == 2 then self._view:GetChild('wanfa_text').text = '二人三千分' .. room.score_times .. '倍' else self._view:GetChild('wanfa_text').text = '三人三千分' .. room.score_times .. '倍' end else if room.room_config.people_num == 2 then - self._view:GetChild('wanfa_text').text = '二人三千分' .. room.score_times .. '倍' + self._view:GetChild('wanfa_text').text = '二人三千分' .. room.score_times .. '倍' else - self._view:GetChild('wanfa_text').text = '三人三千分' .. room.score_times .. '倍' + self._view:GetChild('wanfa_text').text = '三人三千分' .. room.score_times .. '倍' end end - if self._view:GetChild("shengyu")~=nil then + if self._view:GetChild("shengyu") ~= nil then -- body - if room.room_config.Leaf==1 then + if room.room_config.Leaf == 1 then -- body - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余15张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余15张" else - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余16张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余16张" end end - end function M:RunLeftPoker(list) - -- self._view - self._left_View = UIPackage.CreateObject("Extend_Poker_SanQianFen","Panel_poker") - self._view:AddChild(self._left_View) - self._left_View:Center() - local _left_View = self._left_View - local list_left_card = self._left_View:GetChild("Lst_leftPoker") - list_left_card:RemoveChildrenToPool() - for i = 1, #list do - local item = list_left_card:AddItemFromPool("ui://Extend_Poker_SanQianFen/305") - end + -- self._view + self._left_View = UIPackage.CreateObject("Extend_Poker_SanQianFen", "Panel_poker") + self._view:AddChild(self._left_View) + self._left_View:Center() + local _left_View = self._left_View + local list_left_card = self._left_View:GetChild("Lst_leftPoker") + list_left_card:RemoveChildrenToPool() + for i = 1, #list do + local item = list_left_card:AddItemFromPool("ui://Extend_Poker_SanQianFen/305") + end self._left_View:GetTransition("t0"):Play() - - coroutine.start(function() - coroutine.wait(1.5) - _left_View:Dispose() - -- self._popEvent = true - end) + + coroutine.start(function() + coroutine.wait(1.5) + _left_View:Dispose() + -- self._popEvent = true + end) end -function M:UpdateCard( index ) - self._room.pai=index +function M:UpdateCard(index) + self._room.pai = index local card_info = self._player_card_info[1] -- for i=1,#self._room.player_list do - -- print(i) + -- -- print(i) -- end card_info:updatePoker() for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + if self._room.curren_turn_seat ~= player.seat then if player.out_card_list[1] == 0 then player_card_info:SetOutCardInfo(nil, true) @@ -286,7 +281,7 @@ function M:UpdateCard( index ) end end end - if self.caozuo==1 then + if self.caozuo == 1 then local ctr_number = self.pass == nil and 2 or 1 local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) local cardType, cardNum, cardLength = self._gamectr:GetCardListInfo(lastCardList) @@ -299,12 +294,12 @@ function M:UpdateCard( index ) m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength,m) + self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength, m) end end function M:UpdateCardSize(index) - self._room.cardsize=index + self._room.cardsize = index local card_info = self._player_card_info[1] card_info:updatePoker() end @@ -318,7 +313,7 @@ end function M:OnPlayerEnter(...) MainView.OnPlayerEnter(self, ...) - local arg = {...} + local arg = { ... } local p = arg[1] local index = self:GetPos(p.seat) local info = self._player_info[index] @@ -333,7 +328,7 @@ function M:OnPlayerEnter(...) end function M:OnPlayerReady(...) - local arg = {...} + local arg = { ... } local p = arg[1] local _room = self._room local _player_info = self._player_info @@ -342,18 +337,18 @@ function M:OnPlayerReady(...) end local info = _player_info[self:GetPos(p.seat)] info:Ready(true) ---local readyNum = 0 ---for i = 1, #_room.player_list do --- local player = _room.player_list[i] --- if player.ready then readyNum = readyNum + 1 end ---end ---if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then --- if self._state.selectedIndex == 2 then --- local _gamectr = ControllerManager.GetController(GameController) --- _gamectr:StartGame() --- end --- --self._ctr_action.selectedIndex = 2 ---end + --local readyNum = 0 + --for i = 1, #_room.player_list do + -- local player = _room.player_list[i] + -- if player.ready then readyNum = readyNum + 1 end + --end + --if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then + -- if self._state.selectedIndex == 2 then + -- local _gamectr = ControllerManager.GetController(GameController) + -- _gamectr:StartGame() + -- end + -- --self._ctr_action.selectedIndex = 2 + --end end function M:OnPlayerLeave(...) @@ -361,91 +356,84 @@ function M:OnPlayerLeave(...) local _room = self._room if not _room.self_player.ready then --self._ctr_action.selectedIndex = 1 - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else self._ctr_action.selectedIndex = 0 end end - function M:EventInit() local _gamectr = ControllerManager.GetController(GameController) MainView.EventInit(self) local _player_info = self._player_info local _player_card_info = self._player_card_info local _room = self._room - + --local head_info = _player_info[1] --head_info.shangyouObj.visible = true - _gamectr:AddEventListener(SanQianFen_GameEvent.EventXiPai,function( ... ) - - if self.result_view ~= nil then + _gamectr:AddEventListener(SanQianFen_GameEvent.EventXiPai, function(...) + if self.result_view ~= nil then self.result_view:Destroy() self.result_view = nil end - - self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + self._player_card_info[1]:HidePiao() + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then self.rank_view:Dispose() self.rank_view = nil end - - local list = _room.player_list + + local list = _room.player_list for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - - end - - - --[[if ( currentPlayer ) then + end + + + --[[if ( currentPlayer ) then self._popEvent = false local xipaiCB=function () self._popEvent = true @@ -462,34 +450,29 @@ function M:EventInit() end--]] - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] - self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - - end - - - if ( currentPlayer2 ) then - --self._popEvent = false - local xipaiCB2=function () - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end - - - - end) + local arg = { ... } + local currentPlayer1 = arg[1] + local currentPlayer2 = arg[2] + self._popEvent = false + if (currentPlayer1) then + local xipaiCB = function() + self._popEvent = true + end + self:PlayXiPai(xipaiCB) + end + + + if (currentPlayer2) then + --self._popEvent = false + local xipaiCB2 = function() + self._popEvent = true + end + self:PlayXiPai1(xipaiCB2) + end + end) _gamectr:AddEventListener(SanQianFen_GameEvent.OnMingCard, function(...) - local arg = {...} + local arg = { ... } local card = arg[1] self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 1 @@ -497,30 +480,28 @@ function M:EventInit() end) _gamectr:AddEventListener(SanQianFen_GameEvent.OnUpdateXISCORE, function(...) - local arg = {...} + local arg = { ... } local scoreList = arg[1] - + for i = 1, #scoreList do local aid = scoreList[i].aid local juXiFen = scoreList[i].juXiFen local allXiFen = scoreList[i].allXiFen local p = self._room:GetPlayerById(aid) - + local head_info = self._player_info[self:GetPos(p.seat)] - -- head_info._view:GetChild("zong"):GetChild('xi_ju').text = juXiFen - -- head_info._view:GetChild("zong"):GetChild('xi_zong').text = allXiFen - head_info.xi_zong.text = allXiFen - + -- head_info._view:GetChild("zong"):GetChild('xi_ju').text = juXiFen + -- head_info._view:GetChild("zong"):GetChild('xi_zong').text = allXiFen + head_info.xi_zong.text = allXiFen end -- printlog("aaaaaaaaaaaaaaaa "," ",cur510kFen) - + --self.AllScore.text = "总分:"..cur510kFen end) - + _gamectr:AddEventListener(SanQianFen_GameEvent.OnUpdate510KScore, function(...) - printlog("77777777777777777777777777888888888888888888888") - local arg = {...} + local arg = { ... } local cur510kFen = arg[2] local scoreList = arg[1] for i = 1, #scoreList do @@ -529,13 +510,12 @@ function M:EventInit() local all510kfen = scoreList[i].all510kfen local ju510kfen = scoreList[i].ju510kfen local p = self._room:GetPlayerById(aid) - + local head_info = self._player_info[self:GetPos(p.seat)] - -- head_info._view:GetChild('510score').text = all510kfen - local zong = head_info._view:GetChild("zong") - head_info.score_ju.text = ju510kfen - head_info.score_zong.text = all510kfen - + -- head_info._view:GetChild('510score').text = all510kfen + local zong = head_info._view:GetChild("zong") + head_info.score_ju.text = ju510kfen + head_info.score_zong.text = all510kfen end -- local xy = self.FlyScore.xy -- if scoreList[1].add510kfen > 0 then @@ -545,10 +525,10 @@ function M:EventInit() -- self.num_5.text = "0" -- self.num_10.text = "0" -- self.num_k.text = "0" - + -- local p = self._room:GetPlayerById(aid1) -- local head_info = self._player_info[self:GetPos(p.seat)] - + -- local target_xy = self._view:GlobalToLocal(head_info._view:LocalToGlobal(Vector2(50,189))) -- local diff_x = target_xy.x - xy.x -- local diff_y = target_xy.y - xy.y @@ -556,20 +536,15 @@ function M:EventInit() -- self.FlyScore.x = xy.x + diff_x * value -- self.FlyScore.y = xy.y + diff_y * value -- end):OnComplete(function () - + -- self.FlyScore.visible = false -- self.FlyScore.xy = self.FlyScoreXY -- end) -- end - - - - - end) _gamectr:AddEventListener(SanQianFen_GameEvent.OnUpdateALL510KSCORE, function(...) - local arg = {...} + local arg = { ... } local scoreList = arg[1] --printlog("更新总分数==========================") --pt(scoreList) @@ -577,7 +552,6 @@ function M:EventInit() -- coroutine.stop(self.coroutineUpdate510KScore) -- end for i = 1, #scoreList do - local aid = scoreList[i].aid local ju510kfen = scoreList[i].ju510kfen local all510kfen = scoreList[i].all510kfen @@ -595,13 +569,12 @@ function M:EventInit() p.juXiFen = juXiFen p.ju510kFen = ju510kfen p.curXiFen = curXiFen - printlog("wwwwwwwwwwwwwwww ",all510kfen) - + printlog("wwwwwwwwwwwwwwww ", all510kfen) end end) - + _gamectr:AddEventListener(SanQianFen_GameEvent.OnInitCard, function(...) - local arg = {...} + local arg = { ... } local round = arg[1] local cardlist = arg[2] @@ -611,21 +584,21 @@ function M:EventInit() self.result_view = nil end - + self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -638,50 +611,45 @@ function M:EventInit() for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - + if p.seat == self._room.self_player.seat then - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body - card_info:InitPoker(cardlist,true,1) + card_info:InitPoker(cardlist, true, 1) else - card_info:InitPoker(cardlist,true) + card_info:InitPoker(cardlist, true) end - else --card_info:UpdateHandPoker(#cardlist,true,false) --todo --card_info:UpdateRemainCard(#cardlist,true) end - -- head_info.xi_ju.text = "0" - + -- head_info.xi_ju.text = "0" + head_info.score_ju.text = "0" - end end) - - + + -- _gamectr:AddEventListener(SanQianFen_GameEvent.Oener,function ( ... ) -- local arg = {...} -- local seat = arg[1] @@ -689,11 +657,11 @@ function M:EventInit() -- head_info._view:GetController("Oener").selectedIndex=1 -- end) _gamectr:AddEventListener(SanQianFen_GameEvent.OnIndexMove, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local isNewBout = arg[2] local index = self:GetPos(seat) - + self.ctr_time.selectedIndex = index -- for i=1,#self._player_info do -- if index==i then @@ -705,16 +673,16 @@ function M:EventInit() -- head_info:MarkBank(false) -- end -- end - + if index == 1 then local card_info = self._player_card_info[index] card_info:SetOutCardInfo(nil, false) - -- if self.MypokerList ~= nil then - -- -- body - -- card_info:Clear() - -- card_info:InitPoker(self.MypokerList, false) - -- self.MypokerList = nil - -- end + -- if self.MypokerList ~= nil then + -- -- body + -- card_info:Clear() + -- card_info:InitPoker(self.MypokerList, false) + -- self.MypokerList = nil + -- end end self._left_time = 20 if self._room.ming_card ~= nil then @@ -726,9 +694,9 @@ function M:EventInit() end end end) - + _gamectr:AddEventListener(SanQianFen_GameEvent.OnBombScore, function(...) - local arg = {...} + local arg = { ... } local scoreList = arg[1] -- for i = 1, #scoreList do -- local player = self._room:GetPlayerBySeat(i) @@ -740,7 +708,7 @@ function M:EventInit() end) _gamectr:AddEventListener(SanQianFen_GameEvent.EventShangYou, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local index = self:GetPos(seat) @@ -748,10 +716,10 @@ function M:EventInit() head_info.ctr_shangyou.selectedIndex = 1 end) - - + + _gamectr:AddEventListener(SanQianFen_GameEvent.OnPlaySucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] local card_number = arg[2] local cardstype = arg[3] @@ -764,7 +732,7 @@ function M:EventInit() local cur10Num = arg[10] local curkNum = arg[11] self.ctr_time.selectedIndex = 0 - + if self.num_5 then self.num_5.text = cur5Num @@ -785,19 +753,17 @@ function M:EventInit() -- self.AllScore.text = "总分:"..all510k -- end local index = self:GetPos(p.seat) - if index==1 then - self.caozuo=0 + if index == 1 then + self.caozuo = 0 end local head_info = self._player_info[index] - if head_info._view:GetChild("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil then -- body -- body - if card_number~=nil then + if card_number ~= nil then -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..card_number.."张" + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. card_number .. "张" end - - end local card_info = self._player_card_info[index] card_info:SetOutCardInfo(p.out_card_list, false, true) @@ -811,7 +777,7 @@ function M:EventInit() card_info:DeleteHandCards(p.out_card_list) else card_info:SetRemainCardNumber(card_number == 1) - --card_info:UpdateHandPoker(card_number,false,false) -- todo + --card_info:UpdateHandPoker(card_number,false,false) -- todo end if self._room.is_new_bout == true then for i = 1, #self._room.player_list do @@ -821,11 +787,10 @@ function M:EventInit() card_info_i:SetOutCardInfo(nil, false) end end - + self:_Effect(cardstype, p) - else - if cardstype == 11 and cardstype~=12 then + if cardstype == 11 and cardstype ~= 12 then self:_Effect(cardstype, p) end end @@ -842,41 +807,39 @@ function M:EventInit() ---self:PlaySound(p.self_user.sex, "card_1") end) end - end) - - - _gamectr:AddEventListener(SanQianFen_GameEvent.OnPassSuccCheckCard, function(...) - self._popEvent = false - local arg = {...} - local seat = arg[1] + + + _gamectr:AddEventListener(SanQianFen_GameEvent.OnPassSuccCheckCard, function(...) + self._popEvent = false + local arg = { ... } + local seat = arg[1] local cards = arg[2] --self.MypokerList=cards self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(seat)] - if seat == self._room.self_player.seat then - card_info:ClearCheck() - card_info:InitPoker(cards, false) - - --local player=self._room:GetPlayerBySeat(seat) - --if player.out_card_list[1] == 0 then + if seat == self._room.self_player.seat then + card_info:ClearCheck() + card_info:InitPoker(cards, false) + + --local player=self._room:GetPlayerBySeat(seat) + --if player.out_card_list[1] == 0 then -- player_card_info:SetOutCardInfo(nil, true) --else - --player:SetOutCardInfo({207}, false) - -- end - end - + --player:SetOutCardInfo({207}, false) + -- end + end + self._popEvent = true - end) - + _gamectr:AddEventListener(SanQianFen_GameEvent.OnPassSucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] - + self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(p.seat)] - + --card_info:SetOutCardInfo(nil, false) if p.seat == self._room.self_player.seat and self.MypokerList ~= nil then -- body @@ -887,31 +850,30 @@ function M:EventInit() card_info:SetOutCardInfo(nil, true) self:PlaySound(p.self_user.sex, "pass_" .. math.random(1, 4)) end) - + _gamectr:AddEventListener(SanQianFen_GameEvent.OnErrorTip, function(...) - local arg = {...} + local arg = { ... } local error_str = arg[1] self._player_card_info[1]:ErrorTip(error_str) -- self._player_card_info[1]:ResetPoker() end) - + _gamectr:AddEventListener(SanQianFen_GameEvent.OnPiaoTips, function(...) - local arg = {...} + local arg = { ... } local piao = arg[1] local reload = arg[2] if reload == 0 then - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -933,12 +895,12 @@ function M:EventInit() head_info:UpdatePiao(-1) end end - + self._player_card_info[1]:ShowPiao(piao) end) _gamectr:AddEventListener(SanQianFen_GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] @@ -946,15 +908,15 @@ function M:EventInit() end) _gamectr:AddEventListener(SanQianFen_GameEvent.OnOptions, function(...) - local arg = {...} + local arg = { ... } local play = arg[1] local pass = arg[5] local card_type = arg[2] local card_number = arg[3] local card_length = arg[4] local ctr_number = pass == nil and 2 or 1 - self.caozuo=1 --记录是否是自己出牌的阶段 - self.pass=pass + self.caozuo = 1 --记录是否是自己出牌的阶段 + self.pass = pass local m = false local next_seat = self._room.self_player.seat + 1 local card_info = self._player_card_info[1] @@ -972,19 +934,19 @@ function M:EventInit() m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length,m,play,zdts) + self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) end) - -- 托管 - _gamectr:AddEventListener(SanQianFen_GameEvent.Game_TuoGuan, function(...) - local arg = {...} + -- 托管 + _gamectr:AddEventListener(SanQianFen_GameEvent.Game_TuoGuan, function(...) + local arg = { ... } local tuoguan = arg[1] local seat = arg[2] - + local tuoguanzhong = self._view:GetChild("tuoguanzhong") local zhezhao = self._view:GetChild("n109") local head_info = self._player_info[self:GetPos(seat)] if (tuoguan == 1) then - if (seat == self._room.self_player.seat ) then + if (seat == self._room.self_player.seat) then tuoguanzhong.visible = true -- tuoguanzhong.sortingOrder = 2 zhezhao.visible = true @@ -994,10 +956,10 @@ function M:EventInit() else head_info._view:GetController("tuoguan").selectedIndex = 1 end - -- if self.ispanguangzhe == true then - -- -- body - -- zhezhao.visible = false - -- end + -- if self.ispanguangzhe == true then + -- -- body + -- zhezhao.visible = false + -- end else if (seat == self._room.self_player.seat) then tuoguanzhong.visible = false @@ -1013,14 +975,14 @@ function M:EventInit() end end) _gamectr:AddEventListener(SanQianFen_GameEvent.OnResult, function(...) - local arg = {...} + local arg = { ... } local over = arg[1] local info = arg[2] local win_seat = arg[3] local remaincards = arg[4] -- local energyTab = arg[5] local otherpoker_list = self._view:GetChild("otherpoker_list") - + if self.MypokerList ~= nil then -- body local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)] @@ -1031,12 +993,12 @@ function M:EventInit() if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end - - if remaincards then + + if remaincards then -- body - local newremaincards = _gamectr:ChangeCodeByFrom(remaincards,true) + local newremaincards = _gamectr:ChangeCodeByFrom(remaincards, true) table.sort(remaincards) for i = #newremaincards, 1, -1 do coroutine.start(function() @@ -1046,27 +1008,27 @@ function M:EventInit() local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_SanQianFen", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj = nil - if DataManager.CurrenRoom.pai==0 then - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if DataManager.CurrenRoom.pai == 0 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card_n .. + "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/"..card_n) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card_n) end - else - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/"..card_n.."_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card_n .. + "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - end if card_code_obj ~= nil then card_code_obj:SetScale(0.6, 0.6) @@ -1076,29 +1038,24 @@ function M:EventInit() otherpoker_list:AddChild(poker_item) end end - end - end) - - end - end if self._cor_sound ~= nil then coroutine.stop(self._cor_sound) self._cor_sound = nil end - - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) + + if self.destory_win ~= nil then + coroutine.stop(self.destory_win) end - + self.destory_win = nil self.destory_win = coroutine.start(function() - -- print("11111111111111") + -- -- print("11111111111111") -- coroutine.wait(1) - if self._room.self_player.seat == win_seat then + if self._room.self_player.seat == win_seat then local sprint_seat_list = self:GetSpringSeats(info) if #sprint_seat_list > 0 then local url = "ui://Extend_Poker_SanQianFen/Spring" @@ -1109,33 +1066,29 @@ function M:EventInit() ViewUtil.PlaySound("SanQianFen_PK", "base/common/sound/win new.mp3") end -- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_SanQianFen/Spring" or "ui://Extend_Poker_SanQianFen/Win_Mine" - - else local beigang = false - if #self:GetSpringSeats(info)>0 then - for i=1,#self:GetSpringSeats(info) do - if self:GetSpringSeats(info)[i]==self._room.self_player.seat then - local url = "ui://Extend_Poker_SanQianFen/spring2" + if #self:GetSpringSeats(info) > 0 then + for i = 1, #self:GetSpringSeats(info) do + if self:GetSpringSeats(info)[i] == self._room.self_player.seat then + local url = "ui://Extend_Poker_SanQianFen/spring2" self.WinItem_view = UIPackage.CreateObjectFromURL(url) self._view:AddChild(self.WinItem_view) self.WinItem_view:Center() self.WinItem_view:GetTransition("t0"):Play() - beigang=true + beigang = true end end - end -- if beigang == false then -- self:CreateRankEff() -- end - end for i = 1, #info do local player = info[i] local p = self._room:GetPlayerBySeat(player.seat) local head_info = self._player_info[self:GetPos(player.seat)] - + --head_info.ctr_shangyou.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(player.seat)] if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then @@ -1157,13 +1110,13 @@ function M:EventInit() rt = self._room.score_times end if over == 1 and self._room.hpOnOff == 1 then - head_info:UpdateScore(player.score / 10) --不可负分 + head_info:UpdateScore(player.score / 10) --不可负分 else head_info:UpdateScore(player.score * rt) end card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) end - + if player.seat ~= self._room.self_player.seat then card_info:UpdateHandPoker(player.cards, false, true) @@ -1173,39 +1126,39 @@ function M:EventInit() self:ChangeBgmMusic(1) -- if over == 0 then if #self:GetSpringSeats(info) > 0 then - -- print("222222222222222222") + -- -- print("222222222222222222") coroutine.wait(1) else - -- print("333333333333333333") + -- -- print("333333333333333333") -- coroutine.wait(2) end - self._left_View = UIPackage.CreateObject("Extend_Poker_SanQianFen","Panel_poker") + self._left_View = UIPackage.CreateObject("Extend_Poker_SanQianFen", "Panel_poker") self._view:AddChild(self._left_View) self._left_View:Center() local _left_View = self._left_View local list_left_card = self._left_View:GetChild("Lst_leftPoker") list_left_card:RemoveChildrenToPool() - for i = 1, #remaincards do - local x = remaincards[i] % 100 + for i = 1, #remaincards do + local x = remaincards[i] % 100 local t = remaincards[i] if x == 8 then - t = remaincards[i] - 3 + t = remaincards[i] - 3 end - local item = list_left_card:AddItemFromPool("ui://Extend_Poker_SanQianFen/"..t) + local item = list_left_card:AddItemFromPool("ui://Extend_Poker_SanQianFen/" .. t) end self._left_View:GetTransition("t0"):Play() coroutine.wait(2) for i = 1, #info do - local head_info1 = self._player_info[i] head_info1.ctr_shangyou.selectedIndex = 0 end _left_View:Dispose() - - - self.result_view = SanQianFen_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, remaincards) + + + self.result_view = SanQianFen_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, + remaincards) self.result_view:Show() if self.WinItem_view ~= nil then self.WinItem_view:Dispose() @@ -1217,36 +1170,34 @@ function M:EventInit() end if self._room.self_player.entrust == true then - local btn_confirm = self.result_view._view:GetChild("btn_confirm") + local btn_confirm = self.result_view._view:GetChild("btn_confirm") btn_confirm.onClick:Call() end - end) - if over==1 then + if over == 1 then -- body self:UnmarkSelfTuoguan() ControllerManager.ChangeController(LoddyController) - end end) - - _gamectr:AddEventListener(SanQianFen_GameEvent.OnResultByDissolve, function(...) - - local arg = {...} - local over = arg[1] - local info = arg[2] - local winseat = arg[3] - local dissolve = arg[4] - self.result_view = SanQianFen_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve,nil) - self.result_view:Show() - ControllerManager.ChangeController(LoddyController) - self:UnmarkSelfTuoguan() + _gamectr:AddEventListener(SanQianFen_GameEvent.OnResultByDissolve, function(...) + local arg = { ... } + local over = arg[1] + local info = arg[2] + local winseat = arg[3] + local dissolve = arg[4] + + self.result_view = SanQianFen_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, + nil) + self.result_view:Show() + ControllerManager.ChangeController(LoddyController) + self:UnmarkSelfTuoguan() end) - + -- 确定开始下一局 成功 _gamectr:AddEventListener(SanQianFen_GameEvent.OnConfrimToNextGameSucc, function(...) - local arg = {...} + local arg = { ... } local aid = arg[1] local p = self._room:GetPlayerById(aid) if p.seat == self._room.self_player.seat then @@ -1265,10 +1216,10 @@ function M:EventInit() local otherpoker_list = self._view:GetChild("otherpoker_list") if otherpoker_list ~= nil then -- body - otherpoker_list.visible=false + otherpoker_list.visible = false otherpoker_list:RemoveChildrenToPool() end - --player_head._view:GetController("Oener").selectedIndex=0 + --player_head._view:GetController("Oener").selectedIndex=0 end end local player_info = self._player_info[self:GetPos(p.seat)] @@ -1277,18 +1228,17 @@ function M:EventInit() end function M:ReConnectForStart() - local _gamectr = ControllerManager.GetController(GameController) self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat) self._state.selectedIndex = 1 self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat) - + self:UpdateRound(self._room.curren_round) --self.AllScore.text = "总分:"..self._room.cur510kFen self.num_5.text = self._room.cur5Num self.num_10.text = self._room.cur10Num self.num_k.text = self._room.curkNum - self.num_zong.text =self._room.cur510kFen + self.num_zong.text = self._room.cur510kFen for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] local head_info = self._player_info[self:GetPos(player.seat)] @@ -1313,40 +1263,33 @@ function M:ReConnectForStart() end head_info:UpdateScore(player.total_score * rt) end - + head_info:UpdateLineState(player.line_state) head_info:UpdatePiao(player.piao) - - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - - if self._room.room_config.showlength==1 then + + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" end if player.seat == self._room.self_player.seat then - if player.open ~= nil and player.open == 0 and self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if player.open ~= nil and player.open == 0 and self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = player.hand_list player_card_info:InitPoker(player.hand_list, false, 1) - else - player_card_info:InitPoker(player.hand_list, false) end - else - player_card_info:SetRemainCardNumber(player.hand_count == 1) if player.hand_count == 1 then self.bgm_index = 2 @@ -1371,13 +1314,13 @@ function M:ReconnectForClearing() self.num_5.text = self._room.cur5Num self.num_10.text = self._room.cur10Num self.num_k.text = self._room.curkNum - self.num_zong.text =self._room.cur510kFen + self.num_zong.text = self._room.cur510kFen local win_seat = 0 --self.rank_view = self:CreateRankEff(self._room.winseat) for _, player in ipairs(self._room.player_list) do local head_info = self._player_info[self:GetPos(player.seat)] local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + --如果是体力值不可负分模式 则显示当前的hp值 if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) @@ -1403,87 +1346,82 @@ function M:ReconnectForClearing() head_info:UpdateLineState(player.line_state) --head_info._view:GetController("Oener").selectedIndex=0 head_info:UpdatePiao(player.piao) - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then - -- body - head_info._view:GetController("shengyu").selectedIndex=1 - else - head_info._view:GetController("shengyu").selectedIndex=0 - end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - end - - - if player.seat == self._room.self_player.seat then + if self._room.room_config.showlength == 1 then + -- body + head_info._view:GetController("shengyu").selectedIndex = 1 + else + head_info._view:GetController("shengyu").selectedIndex = 0 + end + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" + end + + + if player.seat == self._room.self_player.seat then player_card_info:InitPoker(player.hand_list, false) else player_card_info:UpdateHandPoker(player.hand_list, false, true) end if player.out_card_list[1] == 0 then - player_card_info:SetOutCardInfo(nil, false) else player_card_info:SetOutCardInfo(player.out_card_list, false) end end - win_seat=self._room.winseat + win_seat = self._room.winseat self._room.winseat = nil - + local remaincards = self._room.remaincards - if self._room.game_status==1 then - - + if self._room.game_status == 1 then -- body coroutine.start(function() coroutine.wait(0.3) - - self.result_view = SanQianFen_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat,0,remaincards) - self.result_view:Show() - local card_info = self._player_card_info[1] - card_info._view:GetChild("out_card_list").visible=true - end) - if remaincards then - local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards,true) - + self.result_view = SanQianFen_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, + win_seat, 0, remaincards) + self.result_view:Show() + local card_info = self._player_card_info[1] + card_info._view:GetChild("out_card_list").visible = true + end) + if remaincards then + local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards, true) + -- body local otherpoker_list = self._view:GetChild("otherpoker_list") - + if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end for i = #newremaincards, 1, -1 do coroutine.start(function() coroutine.wait(0.1 * (15 - i)) - + local flow = newremaincards[i] % 10 local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_SanQianFen", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj - - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/"..card_n) + + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card_n) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card_n .. "_1") end if card_code_obj then card_code_obj:SetScale(0.6, 0.6) @@ -1492,7 +1430,7 @@ function M:ReconnectForClearing() end end) end - end + end end end @@ -1503,11 +1441,11 @@ function M:CreateRankEff() self.rank_view:GetTransition("t0"):Play() end -function M:_Effect( type1 ,player) +function M:_Effect(type1, player) -- body - - if type1 < 7 and type1 ~= 4 and type1 ~= 5 then - return + + if type1 < 7 and type1 ~= 4 and type1 ~= 5 then + return end local eff_code = 0 if type1 == 10 then @@ -1525,35 +1463,35 @@ function M:_Effect( type1 ,player) end local info = self._player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai - local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/eff_"..eff_code) + local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/eff_" .. eff_code) -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/eff2_1") effect.touchable = false effect:GetTransition("t0"):Play() -- effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - if eff_code==3 then + if eff_code == 3 then self._view:AddChild(effect) else pNode:AddChild(effect) end - - if eff_code==1 then + + if eff_code == 1 then self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/eff_feiji") self._view:AddChild(self.eff_feiji) self.eff_feiji:Center() self.eff_feiji:GetTransition("t0"):Play() end - if eff_code==3 then + if eff_code == 3 then effect:Center() else - if self:GetPos(player.seat)== 1 then - effect.x,effect.y = 0,24 + if self:GetPos(player.seat) == 1 then + effect.x, effect.y = 0, 24 else - effect.x,effect.y = 24,67 + effect.x, effect.y = 24, 67 end end - - + + -- effect:Center() -- if eff_code ==3 then -- coroutine.start(function() @@ -1563,53 +1501,54 @@ function M:_Effect( type1 ,player) -- else coroutine.start(function() coroutine.wait(1) - if self.eff_feiji~=nil then + if self.eff_feiji ~= nil then self.eff_feiji:Dispose() end effect:Dispose() end) -- end end + -- function M:_Effect(type1, player) - -- if type1 < 7 and type1 ~= 4 then return end - -- local eff_code = 0 - -- if type1 == 10 then --顺子 - -- eff_code = 2 - -- elseif type1 == 11 then --炸 - -- eff_code = 3 - -- elseif type1 == 4 then --连对 - -- eff_code = 4 - -- else - -- eff_code = 6 - -- end - -- local info = self._player_card_info[self:GetPos(player.seat)] - -- local pNode = info._mask_liangpai - -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/MovieClip" .. eff_code) - - -- effect.touchable = false - - -- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - -- pNode:AddChild(effect) - -- if type1 == 10 then --顺子 - -- effect.x, effect.y = -400, -200 - -- elseif type1 == 11 then --炸 - -- effect.x, effect.y = -80, -225 - -- elseif type1 == 4 then --连对 - -- effect.x, effect.y = -400, -200 - -- else - -- effect.x, effect.y = -157, -140 - -- end - -- coroutine.start(function() - -- if type1== 10 or type1== 11 or type1== 4 then - -- -- body - -- coroutine.wait(2) - -- effect:Dispose() - -- else - -- coroutine.wait(1.2) - -- effect:Dispose() - -- end - - -- end) +-- if type1 < 7 and type1 ~= 4 then return end +-- local eff_code = 0 +-- if type1 == 10 then --顺子 +-- eff_code = 2 +-- elseif type1 == 11 then --炸 +-- eff_code = 3 +-- elseif type1 == 4 then --连对 +-- eff_code = 4 +-- else +-- eff_code = 6 +-- end +-- local info = self._player_card_info[self:GetPos(player.seat)] +-- local pNode = info._mask_liangpai +-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/MovieClip" .. eff_code) + +-- effect.touchable = false + +-- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) +-- pNode:AddChild(effect) +-- if type1 == 10 then --顺子 +-- effect.x, effect.y = -400, -200 +-- elseif type1 == 11 then --炸 +-- effect.x, effect.y = -80, -225 +-- elseif type1 == 4 then --连对 +-- effect.x, effect.y = -400, -200 +-- else +-- effect.x, effect.y = -157, -140 +-- end +-- coroutine.start(function() +-- if type1== 10 or type1== 11 or type1== 4 then +-- -- body +-- coroutine.wait(2) +-- effect:Dispose() +-- else +-- coroutine.wait(1.2) +-- effect:Dispose() +-- end + +-- end) -- if eff_code ==3 then -- coroutine.start(function() -- coroutine.wait(1) @@ -1631,7 +1570,7 @@ end function M:GetSoundFileName(type, num, isNewBout) local fileName - if num == 8 then num =5 end + if num == 8 then num = 5 end if isNewBout then if type > 6 or type == 4 then if type == 8 or type == 9 then @@ -1684,17 +1623,17 @@ function M:PlayCardEff(card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/"..card) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SanQianFen/" .. card) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") end - if card_code_obj then - card_code_obj:SetScale(1, 1) - poker_obj:AddChild(card_code_obj) - card_code_obj.visible = true - end - + if card_code_obj then + card_code_obj:SetScale(1, 1) + poker_obj:AddChild(card_code_obj) + card_code_obj.visible = true + end + self.tween = TweenUtils.TweenFloat(0, 2340, cor_time, function(x) poker_back.rotationY = x poker_obj.rotationY = -180 + x @@ -1710,7 +1649,6 @@ function M:PlayCardEff(card) coroutine.wait(1) self._popEvent = true end) - end function M:ResetPoker() @@ -1721,8 +1659,7 @@ function M:ResetPoker() end function M:PlaySound(sex, path) - - local sex_path = ViewUtil.Sex_Chat[sex]-- 1 男 2 女 + local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 local sound_path = string.format("extend/poker/sanqianfen/sound/%s/%s.mp3", sex_path, path) ViewUtil.PlaySound("SanQianFen_PK", sound_path) end @@ -1735,11 +1672,12 @@ function M:ChangeBgmMusic(bgm_index) end ViewUtil.PlayMuisc("SanQianFen_PK", string.format("extend/poker/sanqianfen/sound/bgm%d.mp3", 1)) end -function M:OnPlayerEnter( ... ) - local arg = {...} + +function M:OnPlayerEnter(...) + local arg = { ... } local p = arg[1] - for i=1,#self._room.player_list do - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -1748,26 +1686,26 @@ function M:OnPlayerEnter( ... ) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end -- if p ~= self._room.self_player and self._room.room_config.people_num <= 4 and self._room.room_config.people_num >= 3 and self._gamectr:CheckGPS() then -- if self.distance_view then -- self.distance_view:Destroy() - -- end + -- end -- self.distance_view = PlayerDistanceView.new(true) -- self.distance_view:Show() -- end diff --git a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerBackView.lua b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerBackView.lua index 44c60ef1..b74ab836 100644 --- a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerBackView.lua +++ b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerBackView.lua @@ -17,20 +17,20 @@ local SanQianFen_Record_Event = { Evt_result = 'result', Evt_Result = 'Result', Evt_510kFen = '510kFen' - + } local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/sanqianfen/bg/bg1', thumb = 'ui://Extend_Poker_SanQianFen/table_bg1'}, - {id = 2, url = 'extend/poker/sanqianfen/bg/bg2', thumb = 'ui://Extend_Poker_SanQianFen/table_bg2'}, - {id = 3, url = 'extend/poker/sanqianfen/bg/bg3', thumb = 'ui://Extend_Poker_SanQianFen/table_bg3'} + { id = 1, url = 'extend/poker/sanqianfen/bg/bg1', thumb = 'ui://Extend_Poker_SanQianFen/table_bg1' }, + { id = 2, url = 'extend/poker/sanqianfen/bg/bg2', thumb = 'ui://Extend_Poker_SanQianFen/table_bg2' }, + { id = 3, url = 'extend/poker/sanqianfen/bg/bg3', thumb = 'ui://Extend_Poker_SanQianFen/table_bg3' } } --- Create a new function M.new() - setmetatable(M, {__index = PKPlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKPlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'SanQianFen_PlayBackView' self:init() @@ -44,7 +44,8 @@ function M:InitView(url) end self._gamectr = ControllerManager.GetController(GameController) UIPackage.AddPackage('extend/poker/sanqianfen/ui/Extend_Poker_SanQianFen') - PKPlayBackView.InitView(self, 'ui://Extend_Poker_SanQianFen/SanQianFen_Main_' .. self._room.room_config.people_num, default_bg, bg_config) + PKPlayBackView.InitView(self, 'ui://Extend_Poker_SanQianFen/SanQianFen_Main_' .. self._room.room_config.people_num, + default_bg, bg_config) self._tex_round = self._view:GetChild('round') self._player_card_info = {} local _player_card_info = self._player_card_info @@ -56,8 +57,8 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = SanQianFen_RightPanelView.new(self, rightpanel) + + self._rightPanelView = SanQianFen_RightPanelView.new(self, rightpanel) rightpanel:GetChild("btn_setting").onClick:Clear() local view1_510k = self._view:GetChild("10k5") @@ -67,11 +68,11 @@ function M:InitView(url) local tem = self._view:GetChild('player_info' .. i) _player_info[i] = PlayerInfoView.new(tem, self) - local c1 = view1_510k:GetChild('play_name'..i) - local c2 = view1_510k:GetChild('play_lishi'..i) - local c3 = view1_510k:GetChild('play_ju'..i) - local c4 = view1_510k:GetChild('play_zong'..i) - _player_info[i]:InitScoreComp(c1,c3,c2,nil,c4) + local c1 = view1_510k:GetChild('play_name' .. i) + local c2 = view1_510k:GetChild('play_lishi' .. i) + local c3 = view1_510k:GetChild('play_ju' .. i) + local c4 = view1_510k:GetChild('play_zong' .. i) + _player_info[i]:InitScoreComp(c1, c3, c2, nil, c4) end local view_510k = self._view:GetChild("10k5") @@ -85,7 +86,7 @@ function M:InitView(url) self.num_zong.text = "0" local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -105,7 +106,6 @@ function M:InitView(url) self._cmdmap[SanQianFen_Record_Event.Evt_result] = self.Cmdresult self._cmdmap[SanQianFen_Record_Event.Evt_Result] = self.CmdResult self._cmdmap[SanQianFen_Record_Event.Evt_510kFen] = self.CmdCur510kFen - end function M:NewPlayerPokerInfoView(view, index) @@ -116,7 +116,7 @@ function M:NewPlayerPokerInfoView(view, index) end function M:FillRoomData(data) - print("hidezhanji 1111") + -- print("hidezhanji 1111") self._currentStep = 1 local room = DataManager.CurrenRoom local _player_card_info = self._player_card_info @@ -131,9 +131,9 @@ function M:FillRoomData(data) local head_info = self._player_info[self:GetPos(p.seat)] if p.total_hp then - print("hidezhanji 2222") + -- print("hidezhanji 2222") - head_info._view:GetChild('zhanji').visible=false + head_info._view:GetChild('zhanji').visible = false if room.hpOnOff == 1 or room:checkHpNonnegative() then --head_info._view:GetChild('zhanji').visible=true @@ -147,18 +147,17 @@ function M:FillRoomData(data) card_info:UpdateHandPoker(p.hand_list, false, true) end head_info:UpdatePiao(p.piao) - end self:UpdateRound() - + self:GenerateAllStepData(data) self:ShowStep(1) end function M:ShowStep(index) local step = self._step[index] - if step==nil then + if step == nil then return end for i = 1, #step.player_card_data do @@ -168,13 +167,12 @@ function M:ShowStep(index) p.hand_list = step.player_card_data[i].hand_list p.out_card_list = step.player_card_data[i].out_card_list p.hand_left_count = #p.hand_list - + if p.seat ~= self._room.self_player.seat then info:UpdateHandPoker(p.hand_list, false, true) else info:InitPoker(p.hand_list, false) end - end if step.cmd == SanQianFen_Record_Event.Evt_OutCard then @@ -196,9 +194,9 @@ function M:ShowStep(index) end if step.cmd == SanQianFen_Record_Event.Evt_510kFen then - local seat = step.seat + local seat = step.seat --printlog("ccccccccccccccccc ",self:GetPos(seat)) - local head_info = self._player_info[self:GetPos(seat)] + local head_info = self._player_info[self:GetPos(seat)] head_info.score_ju.text = step.cur510kFen.ju510kFen head_info.xi_zong.text = step.cur510kFen.curXiFen head_info.score_zong.text = step.cur510kFen.cur510kFen @@ -233,7 +231,8 @@ function M:ShowStep(index) end if step.cmd == SanQianFen_Record_Event.Evt_Result then local Result = step.Result - self.result_view = SanQianFen_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, Result.winseat, 0, Result.remaincards) + self.result_view = SanQianFen_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, + Result.winseat, 0, Result.remaincards) local num = self._view:GetChildIndex(self._view:GetChild("panel_record")) self._view:AddChildAt(self.result_view._view, num) else @@ -271,15 +270,15 @@ end function M:CmdOutCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd - -- data.cur510kFen = cmd.data.cur510kFen - data.cur5Num = cmd.data.cur5Num - data.cur10Num = cmd.data.cur10Num - data.curkNum = cmd.data.curkNum - data.all510k = cmd.data.all510k --- data.ju510kFen = cmd.data.ju510kFen --- data.curXiFen = cmd.data.curXiFen --- data.juXiFen = cmd.data.juXiFen - + -- data.cur510kFen = cmd.data.cur510kFen + data.cur5Num = cmd.data.cur5Num + data.cur10Num = cmd.data.cur10Num + data.curkNum = cmd.data.curkNum + data.all510k = cmd.data.all510k + -- data.ju510kFen = cmd.data.ju510kFen + -- data.curXiFen = cmd.data.curXiFen + -- data.juXiFen = cmd.data.juXiFen + data.current_out_seat = cmd.seat local u = data.player_card_data[cmd.seat] u.card_list = cmd.data.card @@ -305,6 +304,7 @@ function M:CmdPass(cmd, index) data.cmd = cmd.cmd data.current_out_seat = cmd.seat end + function M:Cmdresult(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -322,7 +322,7 @@ function M:CmdResult(cmd, index) end end -function M:CmdCur510kFen(cmd,index) +function M:CmdCur510kFen(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.seat = cmd.seat diff --git a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerSelfPokerInfoView.lua index 1ab47e95..b0827f31 100644 --- a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_PlayerSelfPokerInfoView.lua @@ -13,18 +13,18 @@ local CardView = { card_code_flower = 0, -- 索引 index = 0, - -- 牌的列数 - index_X = 0, - -- 每一列第几张牌 - index_Y = 0, - -- 原始位置 - old_postion = Vector2.zero, - m_Select = 0, + -- 牌的列数 + index_X = 0, + -- 每一列第几张牌 + index_Y = 0, + -- 原始位置 + old_postion = Vector2.zero, + m_Select = 0, } -local function NewCardView(card, cardcodenum, cardcodeflower,index_X,index_Y) +local function NewCardView(card, cardcodenum, cardcodeflower, index_X, index_Y) local self = {} - setmetatable(self, {__index = CardView}) + setmetatable(self, { __index = CardView }) self.btn_card = card self.card_code_number = cardcodenum self.card_code_flower = cardcodeflower @@ -47,8 +47,8 @@ local SanQianFen_PlayerSelfPokerInfoView = { local M = SanQianFen_PlayerSelfPokerInfoView function M.new(view, mainView) - setmetatable(M, {__index = SanQianFen_PlayerPokerInfoView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = SanQianFen_PlayerPokerInfoView }) + local self = setmetatable({}, { __index = M }) self._view = view self._mainView = mainView self.gameCtr = ControllerManager.GetController(GameController) @@ -94,10 +94,8 @@ function M:init() -- local t = self:ChangeOneCodeByFrom(x[i]) -- printlog("pppppppppppppppppppppppp",t) -- printlog("pppppppppppppppppppppppp111111111",self:ChangeCodeByTo1(t)) - - -- end - + -- end end function M:ChangeOneCodeByFrom(card) @@ -111,11 +109,11 @@ end function M:SortPoker(pokerList) local pokerListSort = {} - for i=1,#pokerList do + for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) pokerListSort[i] = card_number_code end - table.sort(pokerListSort, function (a,b) + table.sort(pokerListSort, function(a, b) return a > b end) @@ -126,22 +124,22 @@ function M:SortPoker(pokerList) local card_num = math.floor(pokerListSort[i] / 10) --printlog("aaaaaaaaaaaaaaa ",card_num) if card_map[card_num] == nil then - card_map[card_num] = {card} - stack[#stack+1] = card_map[card_num] + card_map[card_num] = { card } + stack[#stack + 1] = card_map[card_num] else card_map[card_num][#card_map[card_num] + 1] = card end end --pt(pokerListSort) - - - -- for k, v in pairs(card_map) do + + + -- for k, v in pairs(card_map) do -- if #v >= 0 then -- stack[#stack+1] = v -- end -- end - + -- local stack1 = {} -- for i=#stack,1,-1 do -- stack1[#stack1+1]=stack[i] @@ -149,12 +147,11 @@ function M:SortPoker(pokerList) --printlog("ccccccccccccccccccccccccccc") --pt(stack) return stack - end -function M:isBoomSelect(card,isSelect) +function M:isBoomSelect(card, isSelect) local num = 0 - -- printlog("cccccccccccccccccc111111111 ",card.card_code_flower) + -- printlog("cccccccccccccccccc111111111 ",card.card_code_flower) for i = #self.card_list, 1, -1 do if card.card_code_flower % 100 == self.card_list[i].card_code_flower % 100 then num = num + 1 @@ -164,33 +161,31 @@ function M:isBoomSelect(card,isSelect) --printlog("cccccccccccccccccc222222222222222222 ",num,isSelect) if num > 3 then for i = #self.card_list, 1, -1 do - if card.card_code_flower % 100 == self.card_list[i].card_code_flower % 100 - and self.card_list[i]~=card + if card.card_code_flower % 100 == self.card_list[i].card_code_flower % 100 + and self.card_list[i] ~= card then - self:SetBtnCardColor(self.card_list[i],isSelect and 0.6 or 1) + self:SetBtnCardColor(self.card_list[i], isSelect and 0.6 or 1) self:UpdateCardMove(self.card_list[i].btn_card, isSelect, false) - - elseif self.card_list[i]~=card and isSelect then - self:SetBtnCardColor(self.card_list[i],1) + elseif self.card_list[i] ~= card and isSelect then + self:SetBtnCardColor(self.card_list[i], 1) self:UpdateCardMove(self.card_list[i].btn_card, false, false) end end else - -- self:UpdateCardMove(card,isSelect,false) - -- self:SetBtnCardColor(card,isSelect and 0.6 or 1) + -- self:UpdateCardMove(card,isSelect,false) + -- self:SetBtnCardColor(card,isSelect and 0.6 or 1) end - end function M:test() - + end function M:InitPoker(pokerList, isPlayAni, open) --printlog("ccccccccccccccccccccccccccccc111111111111111") --pt(pokerList) local cs = 1.25 - if DataManager.CurrenRoom.cardsize==0 then + if DataManager.CurrenRoom.cardsize == 0 then cs = 1.35 elseif DataManager.CurrenRoom.cardsize == 1 then cs = 1.25 @@ -202,7 +197,7 @@ function M:InitPoker(pokerList, isPlayAni, open) coroutine.stop(self.cor_init_poker) self.ctr_put_error.selectedIndex = 0 end - -- print(vardump(self.card_list)) + -- -- print(vardump(self.card_list)) self.cor_init_poker = nil self.card_list = {} @@ -210,56 +205,56 @@ function M:InitPoker(pokerList, isPlayAni, open) if isPlayAni == true then self.cor_init_poker = coroutine.start( - function() - self._mainView._popEvent = false - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) - end - --table.sort(pokerList) - local pokerListSort = self:SortPoker(pokerList) - if pokerListSort == nil or #pokerListSort == 0 then - return - end - self.cards_count = #pokerListSort - for i = 1, #pokerListSort do - local pokerListNum = 0 - for j = 1, #pokerListSort[i] do - local card_number_code = pokerListSort[i][j] - local code = self:ChangeCodeByTo1(card_number_code) - --printlog("ccccccccccccccccccccccccccccc2222222222222222 ",code) - - local btn_card = self:CreatPoker(card_number_code, cs, open) - self.card_width = 120 - self.card_hight = 171 - local x, y = 500, (j * 75) - 500 - btn_card:SetXY(x, y) - self.cards_view:AddChild(btn_card) - self.cards_view:SetChildIndex(btn_card, 12 - j) - local card_view = NewCardView(btn_card, card_number_code,code ,i, j) - --存牌堆 - self.card_list[#self.card_list + 1] = card_view - self:AddCardMoveEvent1(card_view) + function() + self._mainView._popEvent = false + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) end - for j = #self.card_list, 1, -1 do - coroutine.wait(0.005) - if pokerListNum == #pokerListSort[i] then - break - end - pokerListNum = pokerListNum + 1 - local card_view = self.card_list[j] - card_view.btn_card:RemoveFromParent() - self.cards_view:AddChild(card_view.btn_card) - card_view.btn_card:TweenMove(self:GetHandCardPos2(card_view, self.cards_count), 0.08) + --table.sort(pokerList) + local pokerListSort = self:SortPoker(pokerList) + if pokerListSort == nil or #pokerListSort == 0 then + return end - end + self.cards_count = #pokerListSort + for i = 1, #pokerListSort do + local pokerListNum = 0 + for j = 1, #pokerListSort[i] do + local card_number_code = pokerListSort[i][j] + local code = self:ChangeCodeByTo1(card_number_code) + --printlog("ccccccccccccccccccccccccccccc2222222222222222 ",code) - self:UpdateHandCardsPos1() - self._mainView._popEvent = true - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + local btn_card = self:CreatPoker(card_number_code, cs, open) + self.card_width = 120 + self.card_hight = 171 + local x, y = 500, (j * 75) - 500 + btn_card:SetXY(x, y) + self.cards_view:AddChild(btn_card) + self.cards_view:SetChildIndex(btn_card, 12 - j) + local card_view = NewCardView(btn_card, card_number_code, code, i, j) + --存牌堆 + self.card_list[#self.card_list + 1] = card_view + self:AddCardMoveEvent1(card_view) + end + for j = #self.card_list, 1, -1 do + coroutine.wait(0.005) + if pokerListNum == #pokerListSort[i] then + break + end + pokerListNum = pokerListNum + 1 + local card_view = self.card_list[j] + card_view.btn_card:RemoveFromParent() + self.cards_view:AddChild(card_view.btn_card) + card_view.btn_card:TweenMove(self:GetHandCardPos2(card_view, self.cards_count), 0.08) + end + end + + self:UpdateHandCardsPos1() + self._mainView._popEvent = true + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + end end - end - ) + ) else --printlog("wwwwwwwwwwwwwwww33333333333333333333333333333") --pt(pokerList) @@ -273,22 +268,22 @@ function M:InitPoker(pokerList, isPlayAni, open) for j = 1, #pokerListSort[i] do local card_number_code = pokerListSort[i][j] local code = self:ChangeCodeByTo1(card_number_code) - -- printlog("ccccccccccccccccccccccccccccc2222222222222222 ",code) - local btn_card = self:CreatPoker(card_number_code, cs, open) - self.card_width = 120 + -- printlog("ccccccccccccccccccccccccccccc2222222222222222 ",code) + local btn_card = self:CreatPoker(card_number_code, cs, open) + self.card_width = 120 self.card_hight = 171 - + self.cards_view:AddChild(btn_card) self.cards_view:SetChildIndex(btn_card, 12 - j) - local card_view = NewCardView(btn_card, card_number_code,code ,i, j) + local card_view = NewCardView(btn_card, card_number_code, code, i, j) --存牌堆 self.card_list[#self.card_list + 1] = card_view self:AddCardMoveEvent1(card_view) end - --存牌堆 - for j = 1, #self.card_list do + --存牌堆 + for j = 1, #self.card_list do local card_view = self.card_list[j] - card_view.btn_card.xy = self:GetHandCardPos2(card_view, self.cards_count,#pokerListSort[i]) + card_view.btn_card.xy = self:GetHandCardPos2(card_view, self.cards_count, #pokerListSort[i]) end end @@ -328,7 +323,6 @@ function M:DeleteHandCard(card_code_number) end end end - end function M:InitPoker1(pokerList, isPlayAni, open) @@ -340,7 +334,7 @@ function M:InitPoker1(pokerList, isPlayAni, open) -- self.zhizhanplay=0 -- self.zhizhanzdts=0 local cs = 1.25 - if DataManager.CurrenRoom.cardsize==0 then + if DataManager.CurrenRoom.cardsize == 0 then cs = 1.35 elseif DataManager.CurrenRoom.cardsize == 1 then cs = 1.25 @@ -351,7 +345,7 @@ function M:InitPoker1(pokerList, isPlayAni, open) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end - -- print(vardump(self.card_list)) + -- -- print(vardump(self.card_list)) self.cor_init_poker = nil self.card_list = {} @@ -359,71 +353,71 @@ function M:InitPoker1(pokerList, isPlayAni, open) if isPlayAni == true then self.cor_init_poker = coroutine.start( - function() - self._mainView._popEvent = false - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) - end - table.sort(pokerList) + function() + self._mainView._popEvent = false + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) + end + table.sort(pokerList) - for i = 1, #pokerList do - local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) - local card_flower_code = pokerList[i] - local btn_card = self:CreatPoker(card_number_code, cs, open) - local x, y = self._view.width / 2 + 100, -200 - btn_card:SetXY(x, y) - btn_card.alpha = 0 - btn_card.touchable = false - -- coroutine.wait(0.05) - self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - self.card_list[#self.card_list + 1] = card_view + for i = 1, #pokerList do + local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) + local card_flower_code = pokerList[i] + local btn_card = self:CreatPoker(card_number_code, cs, open) + local x, y = self._view.width / 2 + 100, -200 + btn_card:SetXY(x, y) + btn_card.alpha = 0 + btn_card.touchable = false + -- coroutine.wait(0.05) + self.cards_view:AddChild(btn_card) + local card_view = NewCardView(btn_card, card_number_code, card_flower_code) + self.card_list[#self.card_list + 1] = card_view - table.sort(self.card_list, tableSortNumber) + table.sort(self.card_list, tableSortNumber) - if i == #pokerList then - for j = 1, #self.card_list do - local card = self.card_list[j] - card.btn_card.touchable = true - if open ~= 1 then - -- body - self:AddCardMoveEvent(card) + if i == #pokerList then + for j = 1, #self.card_list do + local card = self.card_list[j] + card.btn_card.touchable = true + if open ~= 1 then + -- body + self:AddCardMoveEvent(card) + end end end end - end - for j = #self.card_list, 1, -1 do - -- ViewUtil.PlaySound('SanQianFen_PK', 'extend/poker/sanqianfen/sound/mopai.mp3') - local card_view = self.card_list[j] - card_view.index = j - self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) + for j = #self.card_list, 1, -1 do + -- ViewUtil.PlaySound('SanQianFen_PK', 'extend/poker/sanqianfen/sound/mopai.mp3') + local card_view = self.card_list[j] + card_view.index = j + self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) - card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card:SetScale(value, value) - end - ) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card.alpha = value - end - ) - card_view.btn_card.alpha = 1 - end + card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card:SetScale(value, value) + end + ) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card.alpha = value + end + ) + card_view.btn_card.alpha = 1 + end - self._mainView._popEvent = true - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + self._mainView._popEvent = true + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + end end - end - ) + ) else --printlog("wwwwwwwwwwwwwwww33333333333333333333333333333") --pt(pokerList) @@ -450,7 +444,6 @@ function M:InitPoker1(pokerList, isPlayAni, open) end function M:updatePoker() - local templist = {} for i = 1, #self.card_list do templist[#templist + 1] = self.card_list[i].card_code_flower @@ -467,7 +460,7 @@ function M:AddCardMoveEvent(card) if card.btn_card.touchable == false then return end - + local xy = self.cards_view:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) if xy.y > -21 and xy.y < 221 then self.touchBegin = xy @@ -500,21 +493,21 @@ function M:AddCardMoveEvent(card) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -536,25 +529,25 @@ function M:AddCardMoveEvent(card) if card.btn_card.touchable == true then send_card[#send_card + 1] = card self:SetBtnCardColor(card, 1) - --print(vardump(card)) + ---- print(vardump(card)) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -595,8 +588,6 @@ function M:AddCardMoveEvent(card) ) end - - function M:zhizhanxuanpai() --智障选牌 -- body local temp_send_card = {} @@ -665,8 +656,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then + card.btn_card.x < max_x + then self:SetBtnCardColor(card, 0.6) if #send_card1 == 0 then -- body @@ -695,8 +686,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then + card.btn_card.x < max_x + then -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) -- card.card_isTouchable = 1 -- ViewUtil.PlaySound("SanQianFen_PK", "extend/poker/paodekuai/sound/click.mp3") @@ -717,7 +708,7 @@ function M:TouchMoving(context) end end end - --print(vardump(send_card1)) + ---- print(vardump(send_card1)) -- local send_card = {} -- self.send_card = {} -- for i = 1, #self.card_list do @@ -743,26 +734,25 @@ function M:AddCardMoveEvent1(card) self.isMoving = false local xy = self.cards_view:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) self.touchBegin = xy - --printlog("rrrrrrrrrrrrrrrrrrrrrrrrrr000000000000000 ",xy.y) - --pt(self.card_list) + --printlog("rrrrrrrrrrrrrrrrrrrrrrrrrr000000000000000 ",xy.y) + --pt(self.card_list) Stage.inst.onTouchMove:Add(self.touchMoveFun) local button = card.btn_card - card.btn_card.onTouchEnd:Set(function () - + card.btn_card.onTouchEnd:Set(function() self.beginCard = nil - --self:UpdateCardMove(card,not card.btn_card.selected,false) - --self:SetBtnCardColor(card,not card.btn_card.selected and 0.6 or 1) - --self:isBoomSelect(card,not card.btn_card.selected) + --self:UpdateCardMove(card,not card.btn_card.selected,false) + --self:SetBtnCardColor(card,not card.btn_card.selected and 0.6 or 1) + --self:isBoomSelect(card,not card.btn_card.selected) if not self.isMoving then - self:SetBtnCardColor(card,card.m_Select == 0 and 0.6 or 1) + self:SetBtnCardColor(card, card.m_Select == 0 and 0.6 or 1) end - self.isMoving = false - Stage.inst.onTouchMove:Remove(self.touchMoveFun) - + self.isMoving = false + Stage.inst.onTouchMove:Remove(self.touchMoveFun) + -- for i=1,#self.send_card do -- self:UpdateCardMove(self.send_card[i],true,false) - -- self:SetBtnCardColor(self.send_card[i],0.6) + -- self:SetBtnCardColor(self.send_card[i],0.6) -- end -- for i=1,#self.card_list do -- -- printlog("aaaaaaaaaaaaaaaaaaaa 111111111111 ",self.card_list[i].btn_card.selected) @@ -774,33 +764,30 @@ function M:AddCardMoveEvent1(card) -- for i=1,#self.send_card do -- --printlog("aaaaaaaaaaaaaaaaaaaa1111 ",self.send_card[i].btn_card.selected) -- end - end) - -- button.onChanged:Add( - -- function() - -- printlog("aaaaaaaaaa2222222222222222222222222") - -- -- body - -- if card.btn_card.selected == true then - -- --printlog("aaaaaaaaaa3333333333333333") - -- self:SetBtnCardColor(card,0.6) - -- self.send_card[#self.send_card+1] = card - -- --self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - -- else - -- --printlog("aaaaaaaaaa44444444444444444444444") - -- --self:UpdateCardMove(card.btn_card, card.btn_card.selected, false) - - -- self:SetBtnCardColor(card,1) - -- end - -- --self:isBoomSelect(card,not card.btn_card.selected) - -- end - -- ) - + -- button.onChanged:Add( + -- function() + -- printlog("aaaaaaaaaa2222222222222222222222222") + -- -- body + -- if card.btn_card.selected == true then + -- --printlog("aaaaaaaaaa3333333333333333") + -- self:SetBtnCardColor(card,0.6) + -- self.send_card[#self.send_card+1] = card + -- --self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) + -- else + -- --printlog("aaaaaaaaaa44444444444444444444444") + -- --self:UpdateCardMove(card.btn_card, card.btn_card.selected, false) + + -- self:SetBtnCardColor(card,1) + -- end + -- --self:isBoomSelect(card,not card.btn_card.selected) + -- end + -- ) end ) end function M:TouchMoving1(context) - if self.cards_view == nil then return end @@ -809,8 +796,8 @@ function M:TouchMoving1(context) self.isMoving = true self.isTouching = true if xy.y - self.touchBegin.y > 0 then -- 往下边滑 - -- printlog("rrrrrrrrrr1111111111111111111") - + -- printlog("rrrrrrrrrr1111111111111111111") + local max_y = xy.y local min_y = self.touchBegin.y for i = 1, #self.card_list do @@ -818,38 +805,36 @@ function M:TouchMoving1(context) if card.btn_card.touchable == false or card.card_isTouchable == 1 then else if - card.btn_card.y + (self.card_hight / 2 ) - 40 > min_y and - card.btn_card.x < max_y and card.index_X == self.beginCard.index_X - then + card.btn_card.y + (self.card_hight / 2) - 40 > min_y and + card.btn_card.x < max_y and card.index_X == self.beginCard.index_X + then self:SetBtnCardColor(card, 0.6) - elseif self.beginCard and card.index_X == self.beginCard.index_X then + elseif self.beginCard and card.index_X == self.beginCard.index_X then self:SetBtnCardColor(card, 1) end end end elseif xy.y - self.touchBegin.y < 0 then -- 上边滑 - -- printlog("wwwwwwwwwwwwwwwwwwwwwwwww ",xy.y) + -- printlog("wwwwwwwwwwwwwwwwwwwwwwwww ",xy.y) local max_y = self.touchBegin.y local min_y = xy.y for i = 1, #self.card_list do - local card = self.card_list[i] + local card = self.card_list[i] --printlog("rrrrrr4444444444444 ",card.btn_card.y," ",xy.y," ",max_y," ",card.index_X) if - card.btn_card.y + (self.card_hight/2)-40 > min_y and + card.btn_card.y + (self.card_hight / 2) - 40 > min_y and card.btn_card.y < max_y and self.beginCard and card.index_X == self.beginCard.index_X - then + then self:SetBtnCardColor(card, 0.6) - elseif self.beginCard and card.index_X == self.beginCard.index_X then - self:SetBtnCardColor(card, 1) + elseif self.beginCard and card.index_X == self.beginCard.index_X then + self:SetBtnCardColor(card, 1) end - end end --self.send_card = send_card1 end function M:SetBtnCardColor(card, num) - if num == 0.6 then card.m_Select = 1 else @@ -868,8 +853,8 @@ function M:SetBtnCardColor(card, num) -- end if card.btn_card:GetChildAt(0) ~= nil and card.btn_card:GetChildAt(0):GetChildAt(0) ~= nil and - card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil - then + card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil + then -- body card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(num, num, num) end @@ -964,10 +949,9 @@ end function M:SetOutCardBlack() for i = 1, #self.out_card_list do local card = self.out_card_list[i] - if card and card:GetChildAt(0) and card:GetChildAt(0):GetChildAt(0) and card:GetChildAt(0):GetChildAt(0):GetChildAt(0) then - card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(0.7, 0.7, 0.7) - end - + if card and card:GetChildAt(0) and card:GetChildAt(0):GetChildAt(0) and card:GetChildAt(0):GetChildAt(0):GetChildAt(0) then + card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(0.7, 0.7, 0.7) + end end end @@ -995,19 +979,19 @@ function M:SetOutCardList(cardlist, isAnim) if card_code_number == card.card_code_number then card.btn_card.onTouchBegin:Set(nil) self.out_card_list[#self.out_card_list + 1] = card.btn_card - -- printlog("wwwwwwwwwwwwwwwwww44444444444444") + -- printlog("wwwwwwwwwwwwwwwwww44444444444444") list_remove(self.card_list, card) --list_remove(m_card_list,card) -- todo 出牌动画 local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - card.btn_card, - self.out_card_data['maxcount_x'], - 0.7 - ) + i, + #cardlist, + self.cards_view, + card.btn_card, + self.out_card_data['maxcount_x'], + 0.7 + ) card.btn_card:TweenMove(Vector2.New(pos.x, pos_y), time) -- self.tween = TweenUtils.TweenFloat(1, 0.7, time, function(x) -- card.btn_card:GetChildAt(0):SetScale(x, x) @@ -1016,23 +1000,22 @@ function M:SetOutCardList(cardlist, isAnim) break end end - end --self.card_list=m_card_list --printlog("wwwwwwwwwwwwwwwwww55555555555555555555") --pt(self.card_list) self.move_cor = coroutine.start( - function() - coroutine.wait(0.05) - for i = 1, #self.out_card_list do - local card = self.out_card_list[i] - self.cards_view:SetChildIndex(card, i - 1) + function() + coroutine.wait(0.05) + for i = 1, #self.out_card_list do + local card = self.out_card_list[i] + self.cards_view:SetChildIndex(card, i - 1) + end + coroutine.wait(0.1) + ViewUtil.PlaySound('SanQianFen_PK', 'extend/poker/sanqianfen/sound/chupai.mp3') end - coroutine.wait(0.1) - ViewUtil.PlaySound('SanQianFen_PK', 'extend/poker/sanqianfen/sound/chupai.mp3') - end - ) + ) else for i = 1, #cardlist do local poker_item = UIPackage.CreateObject('Extend_Poker_SanQianFen', 'poker7') @@ -1077,19 +1060,19 @@ function M:SetOutCardList(cardlist, isAnim) self.cards_view:AddChild(poker_item) local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - poker_item, - self.out_card_data['maxcount_x'], - 1 - ) + i, + #cardlist, + self.cards_view, + poker_item, + self.out_card_data['maxcount_x'], + 1 + ) poker_item.xy = Vector2.New(pos.x, pos_y) self.out_card_list[#self.out_card_list + 1] = poker_item - if #cardlist> 3 and i == #cardlist then + if #cardlist > 3 and i == #cardlist then if card_num_obj then card_num_obj.visible = true - card_num_obj.text = #cardlist.."张" + card_num_obj.text = #cardlist .. "张" end end end @@ -1100,15 +1083,14 @@ function M:DeleteHandCards(cardlist) -- printlog("wwwwwwwwwwwwwwwwwwwwwwwwwww11111111111111") -- pt(self.card_list) -- pt(cardlist) - for i = 1, #cardlist do - local card_code_number = cardlist[i] - self:DeleteHandCard(card_code_number) - end - self:UpdateHandCardsPos1() + for i = 1, #cardlist do + local card_code_number = cardlist[i] + self:DeleteHandCard(card_code_number) + end + self:UpdateHandCardsPos1() --printlog("cccccccccccccccccccccccccccrrrrrrrrrrrrrrrrrrrrrrr") --pt(self.card_list) --self:UpdateHandCardsPos1() - end function M:UpdateHandCardsPos() @@ -1132,14 +1114,14 @@ function M:UpdateHandCardsPos1(t) CountCards[self.card_list[i].index_X] = CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1 end - -- printlog("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww") + -- printlog("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww") --pt(CountCards) for i = #self.card_list, 1, -1 do local card_view = self.card_list[i] card_view.btn_card:RemoveFromParent() self.cards_view:AddChild(card_view.btn_card) - local num = self:SameNumCode(card_view.card_code_flower%100) - card_view.old_postion = self:GetHandCardPos2(card_view, #CountCards,num) + local num = self:SameNumCode(card_view.card_code_flower % 100) + card_view.old_postion = self:GetHandCardPos2(card_view, #CountCards, num) -- if t == false then -- card_view.btn_card.xy = card_view.old_postion -- else @@ -1150,15 +1132,15 @@ function M:UpdateHandCardsPos1(t) self:ShowCardNum() end -function M:ShowCardNum() - for i=1,#self.card_list do +function M:ShowCardNum() + for i = 1, #self.card_list do if self.card_list[i].index_Y == 1 then local card_num_obj = self.card_list[i].btn_card:GetChildAt(0):GetChild("num") if card_num_obj then - local num = self:SameNumCode(self.card_list[i].card_code_flower%100) + local num = self:SameNumCode(self.card_list[i].card_code_flower % 100) if num > 3 then card_num_obj.visible = true - card_num_obj.text = num.."张" + card_num_obj.text = num .. "张" end end end @@ -1167,7 +1149,7 @@ end function M:SameNumCode(code) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do local numCode = self.card_list[i].card_code_flower % 100 if code == numCode then num = num + 1 @@ -1181,7 +1163,7 @@ function M:ResetPoker() for i = 1, #self.card_list do local card_view = self.card_list[i] self:UpdateCardMove(card_view.btn_card, false, false) - self:SetBtnCardColor(card_view,1) + self:SetBtnCardColor(card_view, 1) end self.send_card = {} self.Reset = false @@ -1221,10 +1203,10 @@ function M:BtnEvent() end local send_card = {} self.send_card = {} - local currentCard={} + local currentCard = {} for i = 1, #self.card_list do local card = self.card_list[i] - table.insert(currentCard,card.card_code_flower) + table.insert(currentCard, card.card_code_flower) -- if card.btn_card.selected then -- send_card[#send_card + 1] = card.card_code_flower -- self.send_card[#self.send_card + 1] = card @@ -1238,7 +1220,7 @@ function M:BtnEvent() if #send_card == 0 then self:ErrorTip('请选择要出的牌 ') else - self.gameCtr:SendCard(send_card,currentCard) + self.gameCtr:SendCard(send_card, currentCard) end end ) @@ -1292,19 +1274,19 @@ function M:ShowTipsCard(index) for j = 1, #item do if item[j] == self.card_list[i] then self:UpdateCardMove(card.btn_card, true, false) - self:SetBtnCardColor(card,0.6) + self:SetBtnCardColor(card, 0.6) isExsit = true end end if isExsit == false then self:UpdateCardMove(card.btn_card, false, false) - self:SetBtnCardColor(card,1) + self:SetBtnCardColor(card, 1) end end end function M:GetHandCardOffset(count) - local start = -74---54 + local start = -74 ---54 local offset = 0 if count > 10 then @@ -1316,9 +1298,9 @@ function M:GetHandCardOffset(count) end --计算手牌位置 -function M:GetHandCardPos2(cards_view, cards,num) +function M:GetHandCardPos2(cards_view, cards, num) local x, y = 0, 0 - local card_width = 120--self.card_width -- 牌的宽度 + local card_width = 120 --self.card_width -- 牌的宽度 local middle_x = self.cards_view.width / 2 local start_x = middle_x - (cards / 2 * (card_width)) x = start_x + (card_width) * (cards_view.index_X - 1) @@ -1340,20 +1322,20 @@ function M:GetHandCardPos2(cards_view, cards,num) -- t = 30 -- end -- end - - y = 104- (t * cards_view.index_Y) + + y = 104 - (t * cards_view.index_Y) return Vector2.New(x, y) end - function M:GetHandCardPos(index, card_count) local x, y = 0, -18 local offset = self:GetHandCardOffset(card_count) - local middle_x =self.cards_view.width / 2 - local start_x = middle_x - (card_count / 2 * (self.card_width + offset)) + (offset / 2)+self.card_width / 2 + local middle_x = self.cards_view.width / 2 + local start_x = middle_x - (card_count / 2 * (self.card_width + offset)) + (offset / 2) + self.card_width / 2 x = start_x + (self.card_width + offset) * (index - 1) return Vector2.New(x, y) end + function M:GetHandCardPos1(index, card_count) local x, y = 0, -18 local offset = self:GetHandCardOffset(card_count) @@ -1363,7 +1345,6 @@ function M:GetHandCardPos1(index, card_count) return x, y end - function M:ErrorTip(error_text) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) @@ -1372,13 +1353,13 @@ function M:ErrorTip(error_text) self.cor_init_poker = nil self.cor_init_poker = coroutine.start( - function() - self.put_error_text.text = error_text - self.ctr_put_error.selectedIndex = 1 - coroutine.wait(2) - self.ctr_put_error.selectedIndex = 0 - end - ) + function() + self.put_error_text.text = error_text + self.ctr_put_error.selectedIndex = 1 + coroutine.wait(2) + self.ctr_put_error.selectedIndex = 0 + end + ) end --SanQianFen_CardType @@ -1397,7 +1378,7 @@ end function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) local tip_list = {} local sidaisan = false - local touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } --printlog("aaaaaaaaaaaaacccccccccccccccccccc11111111111111111111111111111") --pt(self.card_list) local card_map, max_key = self:GetCardMapAndMaxKey(self.card_list) @@ -1489,7 +1470,7 @@ end -- 合并多个list function M:GetMergeAllList(...) - local lists = {...} + local lists = { ... } local merge_list = {} for i = 1, #lists do local list_item = lists[i] @@ -1517,13 +1498,13 @@ function M:CheckOneCard(pokerMap, num, length) end for k, v in pairs(pokerMap) do if k > num and #v == 1 then - one_card_list[#one_card_list + 1] = {v[1]} + one_card_list[#one_card_list + 1] = { v[1] } touch_key_list[#touch_key_list + 1] = k end end for k, v in pairs(pokerMap) do if k > num and #v ~= 1 then - one_card_list[#one_card_list + 1] = {v[1]} + one_card_list[#one_card_list + 1] = { v[1] } touch_key_list[#touch_key_list + 1] = k end end @@ -1538,7 +1519,7 @@ function M:CheckOnePair(pokerMap, num, length) end for k, v in pairs(pokerMap) do -- 从三条和对子里面提取 if #v > 1 and k > num then - one_pair_list[#one_pair_list + 1] = {v[1], v[2]} + one_pair_list[#one_pair_list + 1] = { v[1], v[2] } touch_key_list[#touch_key_list + 1] = k end end @@ -1553,7 +1534,7 @@ function M:CheckThree(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v > 2 and k > num then - three_list[#three_list + 1] = {v[1], v[2], v[3]} + three_list[#three_list + 1] = { v[1], v[2], v[3] } touch_key_list[#touch_key_list + 1] = k end end @@ -1600,8 +1581,8 @@ function M:CheckThreeAndOne(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_one_list[#three_and_one_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_one_list[#three_and_one_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_one_list, touch_key_list @@ -1615,8 +1596,8 @@ function M:CheckThreeAndTwo(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_two_list[#three_and_two_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_two_list[#three_and_two_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_two_list, touch_key_list @@ -1664,17 +1645,16 @@ function M:CheckBomb(pokerMap, num, length) return bomb_list, touch_key_list end end - + for k, v in pairs(pokerMap) do if #v == length and k > num then --printlog("bbbbbbbbbbb ",k," ",num," ",length) bomb_list[#bomb_list + 1] = v touch_key_list[#touch_key_list + 1] = k - end - - - if #v > length then + + + if #v > length then -- if k>num then -- local v1 = membe_clone(v) -- local v2 = {} @@ -1683,16 +1663,16 @@ function M:CheckBomb(pokerMap, num, length) -- end -- bomb_list[#bomb_list + 1] = v2 -- touch_key_list[#touch_key_list + 1] = k - -- end + -- end -- for i=1,#v-length do -- local v1 = membe_clone(v) -- local v2 = {} -- for j=1,length+i do -- v2[#v2+1] = v1[j] - -- end + -- end -- bomb_list[#bomb_list + 1] = v2 -- touch_key_list[#touch_key_list + 1] = k - -- end + -- end bomb_list[#bomb_list + 1] = v touch_key_list[#touch_key_list + 1] = k end @@ -1728,7 +1708,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end if j == i + pair_length - 1 then plane_list[#plane_list + 1] = item_all_list - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end end @@ -1736,7 +1716,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end function M:SetNotTouchCard(touch_key_list, card_map) - local all_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local all_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } for i = 1, #all_key_list do local key = all_key_list[i] local isExsit = self:IsExistByList(touch_key_list, key) @@ -1779,13 +1759,14 @@ function M:GetCardMapAndMaxKey(pokerList) max_key = number end if map[number] == nil then - map[number] = {pokerList[i]} + map[number] = { pokerList[i] } else map[number][#map[number] + 1] = pokerList[i] end end return map, max_key end + function M:CheckOnes(pokerMap, num, length) local one_card_list = {} local touch_key_list = {} @@ -1803,7 +1784,7 @@ function M:CheckOnes(pokerMap, num, length) for i = 0, length - 1 do if l == k + i and l ~= 15 and l ~= 16 then -- body - text[#text + 1] = {p[1]} + text[#text + 1] = { p[1] } text2[#text2 + 1] = l if #text >= length then -- body @@ -1831,6 +1812,7 @@ function M:CheckOnes(pokerMap, num, length) end return one_card_list, touch_key_list, length end + function M:Clear() self:PlayScore(nil) self:SetOutCardInfo(nil, false) @@ -1843,16 +1825,16 @@ end -- function M:Clear1() -- self:PlayScore(nil) -- self:SetOutCardInfo(nil, false) - + -- self.out_card_list = {} - + -- -- self.mask_liangpai:RemoveChildren(0,-1,true) -- end function M:ClearCheck() - self.card_list = {} + self.card_list = {} self.out_card_list = {} - self.cards_view:RemoveChildren(0, -1, true) + self.cards_view:RemoveChildren(0, -1, true) end function M:Destroy() diff --git a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_RightPanelView.lua b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_RightPanelView.lua index 527eb335..c9511402 100644 --- a/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_RightPanelView.lua +++ b/lua_probject/extend_project/extend/poker/sanqianfen/SanQianFen_RightPanelView.lua @@ -1,7 +1,7 @@ local MainRightPanelView = require("Game.View.MainRightPanelView") local SanQianFen_RightPanelView = {} local M = SanQianFen_RightPanelView -local function __init(self,mainView,view) +local function __init(self, mainView, view) local right_panel = view local btn_setting = right_panel:GetChild("btn_setting") @@ -22,17 +22,17 @@ local function __init(self,mainView,view) end end) else - print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) + -- print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) if mainView.dismiss_room_cd_time > 0 then GameApplication.Instance:ShowTips("您还处于解散冷却时间当中,请稍后重试!") else - _gamectr:AskDismissRoom() + _gamectr:AskDismissRoom() end end end) end) - self._tex_data = right_panel:GetChild("tex_data") + self._tex_data = right_panel:GetChild("tex_data") self._tex_time = right_panel:GetChild("tex_time") self._pb_batteryLevel = right_panel:GetChild("pb_batteryLevel") self._xinhao = right_panel:GetController("xinhao") @@ -50,21 +50,22 @@ local function __init(self,mainView,view) self._total_time = 0 self:__UpdateTime() - + -- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true) -- self._timer:Start() end -function SanQianFen_RightPanelView.new(mainView,view) - setmetatable(M, {__index = MainRightPanelView}) - local self = setmetatable({}, {__index = M}) - self.class = "SanQianFen_RightPanelView" - __init(self,mainView,view) +function SanQianFen_RightPanelView.new(mainView, view) + setmetatable(M, { __index = MainRightPanelView }) + local self = setmetatable({}, { __index = M }) + self.class = "SanQianFen_RightPanelView" + __init(self, mainView, view) return self end + function M:__UpdateTime() self._tex_data.text = os.date("%Y-%m-%d") self._tex_time.text = os.date("%H:%M") - if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then + if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then self._pb_batteryLevel.value = GameApplication.Instance:GetBatteryLevel() end @@ -74,7 +75,7 @@ function M:__UpdateTime() local ping = _client:getAveragePingTime() if not ping then return end ping = math.floor(ping / 2) - if ping > 300 then ping =300 end + if ping > 300 then ping = 300 end if ping <= 100 then self.ctr_xh.selectedIndex = 0 elseif ping <= 300 then @@ -85,4 +86,4 @@ function M:__UpdateTime() self._tex_ping.text = ping .. "ms" end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_MainView.lua b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_MainView.lua index 734dcf59..d3484615 100644 --- a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_MainView.lua +++ b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_MainView.lua @@ -12,8 +12,8 @@ local PlayerInfoView = import(".EXPlayerInfoView") local TableBG = import('Game.Data.TableBG') local M = {} function M.new() - setmetatable(M, {__index = PKMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKMainView }) + local self = setmetatable({}, { __index = M }) self.class = "RunFast_MainView" self:init() self._gamectr = ControllerManager.GetController(GameController) @@ -22,19 +22,20 @@ end local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/shengsidu/bg/bg1', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg1'}, - {id = 2, url = 'extend/poker/shengsidu/bg/bg2', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg2'}, - {id = 3, url = 'extend/poker/shengsidu/bg/bg3', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg3'} + { id = 1, url = 'extend/poker/shengsidu/bg/bg1', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg1' }, + { id = 2, url = 'extend/poker/shengsidu/bg/bg2', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg2' }, + { id = 3, url = 'extend/poker/shengsidu/bg/bg3', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg3' } } function M:InitView(url) local room = self._room UIPackage.AddPackage("extend/poker/shengsidu/ui/Extend_Poker_ShengSiDu") - PKMainView.InitView(self, "ui://Extend_Poker_ShengSiDu/RunFast_Main_" .. room.room_config.people_num,nil,1,default_bg,bg_config,nil,"ui://Extend_Poker_ShengSiDu/SettingWindow1") + PKMainView.InitView(self, "ui://Extend_Poker_ShengSiDu/RunFast_Main_" .. room.room_config.people_num, nil, 1, + default_bg, bg_config, nil, "ui://Extend_Poker_ShengSiDu/SettingWindow1") local _room = DataManager.CurrenRoom local user_id = DataManager.SelfUser.account_id - local json_data = Utils.LoadLocalFile(user_id.._room.game_id.."pai") + local json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "pai") if json_data == nil then local _gamectr = self._gamectr self._room.pai = 0 @@ -44,7 +45,7 @@ function M:InitView(url) self._room.pai = pai end - json_data = Utils.LoadLocalFile(user_id.._room.game_id.."cardsize") + json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "cardsize") if json_data == nil then local _gamectr = self._gamectr self._room.cardsize = 1 @@ -63,7 +64,7 @@ function M:InitView(url) tem.visible = false end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -75,11 +76,10 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) - for i=1,#self._room.player_list do - - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + + self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -88,30 +88,30 @@ function M:InitView(url) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end - - if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then + + if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then -- body - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text=self._room.score_times .."倍" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = self._room.score_times .. "倍" else - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text="" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = "" end - + self.ctr_state = self._view:GetController("state") self._ctr_action = self._view:GetController("action") self._tex_leftTime = self._view:GetChild("time"):GetChild("title") @@ -119,15 +119,15 @@ function M:InitView(url) self._text_round = self._view:GetChild("round") self.ctr_card_eff = self._view:GetController("card_eff") self._player_card_info = {} - + local _player_card_info = self._player_card_info for i = 1, room.room_config.people_num do local tem = self._view:GetChild("player_card_info_" .. i) _player_card_info[i] = self:NewPlayerCardInfoView(tem, i) end - + local list = room.player_list - --pt(list) + --pt(list) if not room.self_player.ready then self._ctr_action.selectedIndex = 1 else @@ -143,28 +143,25 @@ function M:InitView(url) self:ReConnectForStart() end else - self._state.selectedIndex = StateType.Palying self:ReconnectForClearing() - end - - self._view:GetChild("btn_back_jiesan").onClick:Set(function () + + self._view:GetChild("btn_back_jiesan").onClick:Set(function() if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) - --local tempdsaf=self._view:GetChild("btn_back_jiesan") - --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) - + --local tempdsaf=self._view:GetChild("btn_back_jiesan") + --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) + --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) + self:ChangeBgmMusic() self:EventInit() - + self._view:GetChild("mask").onClick:Set(function() self:ResetPoker() end) @@ -183,30 +180,31 @@ function M:InitView(url) self._view:GetChild('wanfa_text').text = '十六张' .. '三人跑得快' .. room.score_times .. '倍' end end--]] - - self._view:GetChild('wanfa_text').text =room.room_config.people_num.. '人生死赌' .. room.score_times .. '倍' - if self._view:GetChild("shengyu")~=nil then + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人生死赌' .. room.score_times .. '倍' + + if self._view:GetChild("shengyu") ~= nil then -- body - if room.room_config.Leaf==1 then + if room.room_config.Leaf == 1 then -- body - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余15张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余15张" else - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余16张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余16张" end end end -function M:UpdateCard( index ) - self._room.pai=index + +function M:UpdateCard(index) + self._room.pai = index local card_info = self._player_card_info[1] -- for i=1,#self._room.player_list do - -- print(i) + -- -- print(i) -- end card_info:updatePoker() for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + if self._room.curren_turn_seat ~= player.seat then if player.out_card_list[1] == 0 then player_card_info:SetOutCardInfo(nil, true) @@ -215,10 +213,10 @@ function M:UpdateCard( index ) end end end - if self.caozuo==1 then - local ctr_number = self.pass - local lastCardList,lastRawCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) - local cardType, cardNum, cardLength = self._gamectr:GetCardListInfo(lastCardList,lastRawCardList) + if self.caozuo == 1 then + local ctr_number = self.pass + local lastCardList, lastRawCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) + local cardType, cardNum, cardLength = self._gamectr:GetCardListInfo(lastCardList, lastRawCardList) local m = false local next_seat = self._room.self_player.seat + 1 if next_seat > self._room.room_config.people_num then @@ -228,12 +226,12 @@ function M:UpdateCard( index ) m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength,m) + self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength, m) end end function M:UpdateCardSize(index) - self._room.cardsize=index + self._room.cardsize = index local card_info = self._player_card_info[1] card_info:updatePoker() end @@ -247,7 +245,7 @@ end function M:OnPlayerEnter(...) MainView.OnPlayerEnter(self, ...) - local arg = {...} + local arg = { ... } local p = arg[1] local index = self:GetPos(p.seat) local info = self._player_info[index] @@ -262,7 +260,7 @@ function M:OnPlayerEnter(...) end function M:OnPlayerReady(...) - local arg = {...} + local arg = { ... } local p = arg[1] local _room = self._room local _player_info = self._player_info @@ -271,18 +269,18 @@ function M:OnPlayerReady(...) end local info = _player_info[self:GetPos(p.seat)] info:Ready(true) ---local readyNum = 0 ---for i = 1, #_room.player_list do --- local player = _room.player_list[i] --- if player.ready then readyNum = readyNum + 1 end ---end ---if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then --- if self._state.selectedIndex == 2 then --- local _gamectr = ControllerManager.GetController(GameController) --- _gamectr:StartGame() --- end --- --self._ctr_action.selectedIndex = 2 ---end + --local readyNum = 0 + --for i = 1, #_room.player_list do + -- local player = _room.player_list[i] + -- if player.ready then readyNum = readyNum + 1 end + --end + --if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then + -- if self._state.selectedIndex == 2 then + -- local _gamectr = ControllerManager.GetController(GameController) + -- _gamectr:StartGame() + -- end + -- --self._ctr_action.selectedIndex = 2 + --end end function M:OnPlayerLeave(...) @@ -295,7 +293,6 @@ function M:OnPlayerLeave(...) end end - function M:EventInit() local _gamectr = ControllerManager.GetController(GameController) MainView.EventInit(self) @@ -303,15 +300,15 @@ function M:EventInit() local _player_card_info = self._player_card_info local _room = self._room _gamectr:AddEventListener(RunFast_GameEvent.OnMingCard, function(...) - local arg = {...} + local arg = { ... } local card = arg[1] self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 1 self:PlayCardEff(card) end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnInitCard, function(...) - local arg = {...} + local arg = { ... } local round = arg[1] local cardlist = arg[2] @@ -320,20 +317,20 @@ function M:EventInit() self.result_view:Destroy() self.result_view = nil end - + self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -346,44 +343,40 @@ function M:EventInit() for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - + if p.seat == self._room.self_player.seat then - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body - card_info:InitPoker(cardlist,true,1) + card_info:InitPoker(cardlist, true, 1) else - card_info:InitPoker(cardlist,true) + card_info:InitPoker(cardlist, true) end - else --card_info:UpdateHandPoker(#cardlist,true,false) --todo --card_info:UpdateRemainCard(#cardlist,true) end end end) - - + + -- _gamectr:AddEventListener(RunFast_GameEvent.Oener,function ( ... ) -- local arg = {...} -- local seat = arg[1] @@ -391,11 +384,11 @@ function M:EventInit() -- head_info._view:GetController("Oener").selectedIndex=1 -- end) _gamectr:AddEventListener(RunFast_GameEvent.OnIndexMove, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local isNewBout = arg[2] local index = self:GetPos(seat) - + self.ctr_time.selectedIndex = index -- for i=1,#self._player_info do -- if index==i then @@ -407,16 +400,16 @@ function M:EventInit() -- head_info:MarkBank(false) -- end -- end - + if index == 1 then local card_info = self._player_card_info[index] card_info:SetOutCardInfo(nil, false) - -- if self.MypokerList ~= nil then - -- -- body - -- card_info:Clear() - -- card_info:InitPoker(self.MypokerList, false) - -- self.MypokerList = nil - -- end + -- if self.MypokerList ~= nil then + -- -- body + -- card_info:Clear() + -- card_info:InitPoker(self.MypokerList, false) + -- self.MypokerList = nil + -- end end self._left_time = 20 if self._room.ming_card ~= nil then @@ -428,9 +421,9 @@ function M:EventInit() end end end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnBombScore, function(...) - local arg = {...} + local arg = { ... } local scoreList = arg[1] -- for i = 1, #scoreList do -- local player = self._room:GetPlayerBySeat(i) @@ -440,9 +433,9 @@ function M:EventInit() -- head_info:UpdateScore(player.total_score) -- end end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnPlaySucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] local card_number = arg[2] local cardstype = arg[3] @@ -450,21 +443,19 @@ function M:EventInit() local otherList = arg[5] local length = arg[6] self.ctr_time.selectedIndex = 0 - + local index = self:GetPos(p.seat) - if index==1 then - self.caozuo=0 + if index == 1 then + self.caozuo = 0 end local head_info = self._player_info[index] - if head_info._view:GetChild("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil then -- body -- body - if card_number~=nil then + if card_number ~= nil then -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..card_number.."张" + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. card_number .. "张" end - - end local card_info = self._player_card_info[index] card_info:SetOutCardInfo(p.out_card_list, false, true) @@ -477,7 +468,7 @@ function M:EventInit() card_info:DeleteHandCards(p.out_card_list) else card_info:SetRemainCardNumber(card_number == 1) - --card_info:UpdateHandPoker(card_number,false,false) -- todo + --card_info:UpdateHandPoker(card_number,false,false) -- todo end if self._room.is_new_bout == true then for i = 1, #self._room.player_list do @@ -490,13 +481,13 @@ function M:EventInit() -- card_info:PlayCardTypeEff(cardstype) -- if cardstype~=12 then -- -- body - - + + -- if cardstype==10 and length>=6 then -- -- card_info_i -- local chuan = UIPackage.CreateObject("Extend_Poker_RunFast", "chuan1") -- local card_info_i = self._player_card_info[self:GetPos(p.seat)] - + -- card_info_i._mask_liangpai:AddChild(chuan) -- chuan:GetChild("n0").asMovieClip.playing = true -- ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/sunzi.mp3") @@ -506,7 +497,7 @@ function M:EventInit() -- -- body -- chuan:Dispose() -- end - + -- end) -- else @@ -514,9 +505,8 @@ function M:EventInit() -- end -- end self:_Effect(cardstype, p) - else - if cardstype == 11 and cardstype~=12 then + if cardstype == 11 and cardstype ~= 12 then self:_Effect(cardstype, p) end end @@ -533,16 +523,15 @@ function M:EventInit() self:PlaySound(p.self_user.sex, "card_1") end) end - end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnPassSucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] - + self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(p.seat)] - + --card_info:SetOutCardInfo(nil, false) if p.seat == self._room.self_player.seat and self.MypokerList ~= nil then -- body @@ -553,31 +542,30 @@ function M:EventInit() card_info:SetOutCardInfo(nil, true) self:PlaySound(p.self_user.sex, "pass_" .. math.random(1, 4)) end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnErrorTip, function(...) - local arg = {...} + local arg = { ... } local error_str = arg[1] self._player_card_info[1]:ErrorTip(error_str) -- self._player_card_info[1]:ResetPoker() end) - + _gamectr:AddEventListener(RunFast_GameEvent.OnPiaoTips, function(...) - local arg = {...} + local arg = { ... } local piao = arg[1] local reload = arg[2] if reload == 0 then - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -599,12 +587,12 @@ function M:EventInit() head_info:UpdatePiao(-1) end end - + self._player_card_info[1]:ShowPiao(piao) end) _gamectr:AddEventListener(RunFast_GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] @@ -612,17 +600,17 @@ function M:EventInit() end) _gamectr:AddEventListener(RunFast_GameEvent.OnOptions, function(...) - local arg = {...} + local arg = { ... } local play = arg[1] local pass = arg[5] local card_type = arg[2] local card_number = arg[3] local card_length = arg[4] - + local ctr_number = pass - - self.caozuo=1 --记录是否是自己出牌的阶段 - self.pass=pass + + self.caozuo = 1 --记录是否是自己出牌的阶段 + self.pass = pass local m = false local next_seat = self._room.self_player.seat + 1 local card_info = self._player_card_info[1] @@ -640,19 +628,19 @@ function M:EventInit() m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length,m,play,zdts) + self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) end) - -- 托管 - _gamectr:AddEventListener(RunFast_GameEvent.Game_TuoGuan, function(...) - local arg = {...} + -- 托管 + _gamectr:AddEventListener(RunFast_GameEvent.Game_TuoGuan, function(...) + local arg = { ... } local tuoguan = arg[1] local seat = arg[2] - + local tuoguanzhong = self._view:GetChild("tuoguanzhong") local zhezhao = self._view:GetChild("n109") local head_info = self._player_info[self:GetPos(seat)] if (tuoguan == 1) then - if (seat == self._room.self_player.seat ) then + if (seat == self._room.self_player.seat) then tuoguanzhong.visible = true -- tuoguanzhong.sortingOrder = 2 zhezhao.visible = true @@ -662,10 +650,10 @@ function M:EventInit() else head_info._view:GetController("tuoguan").selectedIndex = 1 end - -- if self.ispanguangzhe == true then - -- -- body - -- zhezhao.visible = false - -- end + -- if self.ispanguangzhe == true then + -- -- body + -- zhezhao.visible = false + -- end else if (seat == self._room.self_player.seat) then tuoguanzhong.visible = false @@ -681,14 +669,14 @@ function M:EventInit() end end) _gamectr:AddEventListener(RunFast_GameEvent.OnResult, function(...) - local arg = {...} + local arg = { ... } local over = arg[1] local info = arg[2] local win_seat = arg[3] local remaincards = arg[4] -- local energyTab = arg[5] local otherpoker_list = self._view:GetChild("otherpoker_list") - + if self.MypokerList ~= nil then -- body local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)] @@ -699,12 +687,12 @@ function M:EventInit() if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end - - if remaincards then + + if remaincards then -- body - local newremaincards = _gamectr:ChangeCodeByFrom(remaincards,true) + local newremaincards = _gamectr:ChangeCodeByFrom(remaincards, true) table.sort(remaincards) for i = #newremaincards, 1, -1 do coroutine.start(function() @@ -714,27 +702,27 @@ function M:EventInit() local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_ShengSiDu", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj = nil - if DataManager.CurrenRoom.pai==0 then - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if DataManager.CurrenRoom.pai == 0 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/"..card_n.."_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card_n .. + "_2") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/"..card_n) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card_n) end - else - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/"..card_n.."_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card_n .. + "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - end if card_code_obj ~= nil then card_code_obj:SetScale(0.6, 0.6) @@ -742,29 +730,24 @@ function M:EventInit() poker_item:AddChild(card_code_obj) otherpoker_list:AddChild(poker_item) end - end - end) - - end - end if self._cor_sound ~= nil then coroutine.stop(self._cor_sound) self._cor_sound = nil end - - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) + + if self.destory_win ~= nil then + coroutine.stop(self.destory_win) end - + self.destory_win = nil self.destory_win = coroutine.start(function() - -- print("11111111111111") + -- -- print("11111111111111") -- coroutine.wait(1) - if self._room.self_player.seat == win_seat then + if self._room.self_player.seat == win_seat then local sprint_seat_list = self:GetSpringSeats(info) if #sprint_seat_list > 0 then local url = "ui://Extend_Poker_ShengSiDu/Spring" @@ -775,27 +758,23 @@ function M:EventInit() ViewUtil.PlaySound("ShengSiDu_PK", "base/common/sound/win new.mp3") end -- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_RunFastNew/Spring" or "ui://Extend_Poker_RunFastNew/Win_Mine" - - else local beigang = false - if #self:GetSpringSeats(info)>0 then - for i=1,#self:GetSpringSeats(info) do - if self:GetSpringSeats(info)[i]==self._room.self_player.seat then - local url = "ui://Extend_Poker_ShengSiDu/spring2" + if #self:GetSpringSeats(info) > 0 then + for i = 1, #self:GetSpringSeats(info) do + if self:GetSpringSeats(info)[i] == self._room.self_player.seat then + local url = "ui://Extend_Poker_ShengSiDu/spring2" self.WinItem_view = UIPackage.CreateObjectFromURL(url) self._view:AddChild(self.WinItem_view) self.WinItem_view:Center() self.WinItem_view:GetTransition("t0"):Play() - beigang=true + beigang = true end end - end -- if beigang == false then -- self:CreateRankEff() -- end - end for i = 1, #info do local player = info[i] @@ -821,13 +800,13 @@ function M:EventInit() rt = self._room.score_times end if over == 1 and self._room.hpOnOff == 1 then - head_info:UpdateScore(player.score / 10) --不可负分 + head_info:UpdateScore(player.score / 10) --不可负分 else head_info:UpdateScore(player.score * rt) end card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) end - + if player.seat ~= self._room.self_player.seat then card_info:UpdateHandPoker(player.cards, false, true) @@ -837,14 +816,15 @@ function M:EventInit() self:ChangeBgmMusic(1) -- if over == 0 then if #self:GetSpringSeats(info) > 0 then - -- print("222222222222222222") + -- -- print("222222222222222222") coroutine.wait(1) else - -- print("333333333333333333") + -- -- print("333333333333333333") -- coroutine.wait(2) end - - self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, remaincards) + + self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, + remaincards) self.result_view:Show() if self.WinItem_view ~= nil then self.WinItem_view:Dispose() @@ -856,50 +836,48 @@ function M:EventInit() end if self._room.self_player.entrust == true then - local btn_confirm = self.result_view._view:GetChild("btn_confirm") + local btn_confirm = self.result_view._view:GetChild("btn_confirm") btn_confirm.onClick:Call() end - -- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow") - -- _actionView.icon = "ui://Common/btn_comfirm" - -- _actionView.onClick:Set(function () - -- --local _gamectr = ControllerManager.GetController(GameController) - -- _gamectr:ConformToNextGame() - -- _actionView:Dispose() - -- end) - -- _actionView.xy = Vector2(900, 625) - -- self._view:AddChild(_actionView) - -- else - -- coroutine.wait(4) - -- self.result_view = RunFast_ResultView.new(self._root_view,info,self._room.room_id) - -- self.result_view:Show() - -- end + -- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow") + -- _actionView.icon = "ui://Common/btn_comfirm" + -- _actionView.onClick:Set(function () + -- --local _gamectr = ControllerManager.GetController(GameController) + -- _gamectr:ConformToNextGame() + -- _actionView:Dispose() + -- end) + -- _actionView.xy = Vector2(900, 625) + -- self._view:AddChild(_actionView) + -- else + -- coroutine.wait(4) + -- self.result_view = RunFast_ResultView.new(self._root_view,info,self._room.room_id) + -- self.result_view:Show() + -- end end) - if over==1 then + if over == 1 then -- body self:UnmarkSelfTuoguan() ControllerManager.ChangeController(LoddyController) - end end) - - _gamectr:AddEventListener(RunFast_GameEvent.OnResultByDissolve, function(...) - - local arg = {...} - local over = arg[1] - local info = arg[2] - local winseat = arg[3] - local dissolve = arg[4] - self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve,nil) - self.result_view:Show() - ControllerManager.ChangeController(LoddyController) - self:UnmarkSelfTuoguan() + _gamectr:AddEventListener(RunFast_GameEvent.OnResultByDissolve, function(...) + local arg = { ... } + local over = arg[1] + local info = arg[2] + local winseat = arg[3] + local dissolve = arg[4] + + self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, nil) + self.result_view:Show() + ControllerManager.ChangeController(LoddyController) + self:UnmarkSelfTuoguan() end) - + -- 确定开始下一局 成功 _gamectr:AddEventListener(RunFast_GameEvent.OnConfrimToNextGameSucc, function(...) - local arg = {...} + local arg = { ... } local aid = arg[1] local p = self._room:GetPlayerById(aid) if p.seat == self._room.self_player.seat then @@ -918,10 +896,10 @@ function M:EventInit() local otherpoker_list = self._view:GetChild("otherpoker_list") if otherpoker_list ~= nil then -- body - otherpoker_list.visible=false + otherpoker_list.visible = false otherpoker_list:RemoveChildrenToPool() end - --player_head._view:GetController("Oener").selectedIndex=0 + --player_head._view:GetController("Oener").selectedIndex=0 end end local player_info = self._player_info[self:GetPos(p.seat)] @@ -930,12 +908,11 @@ function M:EventInit() end function M:ReConnectForStart() - local _gamectr = ControllerManager.GetController(GameController) self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat) self._state.selectedIndex = 1 self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat) - + self:UpdateRound(self._room.curren_round) for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] @@ -961,40 +938,33 @@ function M:ReConnectForStart() end head_info:UpdateScore(player.total_score * rt) end - + head_info:UpdateLineState(player.line_state) head_info:UpdatePiao(player.piao) - - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - - if self._room.room_config.showlength==1 then + + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" end if player.seat == self._room.self_player.seat then - if player.open ~= nil and player.open == 0 and self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if player.open ~= nil and player.open == 0 and self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = player.hand_list player_card_info:InitPoker(player.hand_list, false, 1) - else - player_card_info:InitPoker(player.hand_list, false) end - else - player_card_info:SetRemainCardNumber(player.hand_count == 1) if player.hand_count == 1 then self.bgm_index = 2 @@ -1020,7 +990,7 @@ function M:ReconnectForClearing() for _, player in ipairs(self._room.player_list) do local head_info = self._player_info[self:GetPos(player.seat)] local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + --如果是体力值不可负分模式 则显示当前的hp值 if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) @@ -1046,96 +1016,91 @@ function M:ReconnectForClearing() head_info:UpdateLineState(player.line_state) --head_info._view:GetController("Oener").selectedIndex=0 head_info:UpdatePiao(player.piao) - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then - -- body - head_info._view:GetController("shengyu").selectedIndex=1 - else - head_info._view:GetController("shengyu").selectedIndex=0 - end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - end - - - if player.seat == self._room.self_player.seat then + if self._room.room_config.showlength == 1 then + -- body + head_info._view:GetController("shengyu").selectedIndex = 1 + else + head_info._view:GetController("shengyu").selectedIndex = 0 + end + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" + end + + + if player.seat == self._room.self_player.seat then player_card_info:InitPoker(player.hand_list, false) else player_card_info:UpdateHandPoker(player.hand_list, false, true) end if player.out_card_list[1] == 0 then - player_card_info:SetOutCardInfo(nil, false) else player_card_info:SetOutCardInfo(player.out_card_list, false) end end - win_seat=self._room.winseat + win_seat = self._room.winseat self._room.winseat = nil - + local remaincards = self._room.remaincards - if self._room.game_status==1 then - - + if self._room.game_status == 1 then -- body coroutine.start(function() coroutine.wait(0.3) - - self.result_view = RunFast_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat,0,nil) - self.result_view:Show() - local card_info = self._player_card_info[1] - card_info._view:GetChild("out_card_list").visible=true - end) - if remaincards then - local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards,true) - + self.result_view = RunFast_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, + win_seat, 0, nil) + self.result_view:Show() + local card_info = self._player_card_info[1] + card_info._view:GetChild("out_card_list").visible = true + end) + if remaincards then + local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards, true) + -- body local otherpoker_list = self._view:GetChild("otherpoker_list") - + if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end for i = #newremaincards, 1, -1 do coroutine.start(function() coroutine.wait(0.1 * (15 - i)) - + local flow = newremaincards[i] % 10 local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_ShengSiDu", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/"..card_n) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card_n) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card_n .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card_n .. "_2") end - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card_n .. "_1") end - if card_code_obj then - card_code_obj:SetScale(0.6, 0.6) - poker_item:AddChild(card_code_obj) - end - + if card_code_obj then + card_code_obj:SetScale(0.6, 0.6) + poker_item:AddChild(card_code_obj) + end + otherpoker_list:AddChild(poker_item) end) end - end + end end end @@ -1146,15 +1111,15 @@ function M:CreateRankEff() self.rank_view:GetTransition("t0"):Play() end -function M:_Effect( type1 ,player) +function M:_Effect(type1, player) -- body - - if type1==13 then return printlog("四带一效果==》》》") end - - - - if type1 < 7 and type1 ~= 4 and type1 ~= 5 then - return + + if type1 == 13 then return printlog("四带一效果==》》》") end + + + + if type1 < 7 and type1 ~= 4 and type1 ~= 5 then + return end local eff_code = 0 if type1 == 10 then @@ -1172,35 +1137,35 @@ function M:_Effect( type1 ,player) end local info = self._player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai - local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/eff_"..eff_code) + local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/eff_" .. eff_code) -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff2_1") effect.touchable = false effect:GetTransition("t0"):Play() -- effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - if eff_code==3 then + if eff_code == 3 then self._view:AddChild(effect) else pNode:AddChild(effect) end - - if eff_code==1 then + + if eff_code == 1 then self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/eff_feiji") self._view:AddChild(self.eff_feiji) self.eff_feiji:Center() self.eff_feiji:GetTransition("t0"):Play() end - if eff_code==3 then + if eff_code == 3 then effect:Center() else - if self:GetPos(player.seat)== 1 then - effect.x,effect.y = 0,24 + if self:GetPos(player.seat) == 1 then + effect.x, effect.y = 0, 24 else - effect.x,effect.y = 24,67 + effect.x, effect.y = 24, 67 end end - - + + -- effect:Center() -- if eff_code ==3 then -- coroutine.start(function() @@ -1210,53 +1175,54 @@ function M:_Effect( type1 ,player) -- else coroutine.start(function() coroutine.wait(1) - if self.eff_feiji~=nil then + if self.eff_feiji ~= nil then self.eff_feiji:Dispose() end effect:Dispose() end) -- end end + -- function M:_Effect(type1, player) - -- if type1 < 7 and type1 ~= 4 then return end - -- local eff_code = 0 - -- if type1 == 10 then --顺子 - -- eff_code = 2 - -- elseif type1 == 11 then --炸 - -- eff_code = 3 - -- elseif type1 == 4 then --连对 - -- eff_code = 4 - -- else - -- eff_code = 6 - -- end - -- local info = self._player_card_info[self:GetPos(player.seat)] - -- local pNode = info._mask_liangpai - -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/MovieClip" .. eff_code) - - -- effect.touchable = false - - -- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - -- pNode:AddChild(effect) - -- if type1 == 10 then --顺子 - -- effect.x, effect.y = -400, -200 - -- elseif type1 == 11 then --炸 - -- effect.x, effect.y = -80, -225 - -- elseif type1 == 4 then --连对 - -- effect.x, effect.y = -400, -200 - -- else - -- effect.x, effect.y = -157, -140 - -- end - -- coroutine.start(function() - -- if type1== 10 or type1== 11 or type1== 4 then - -- -- body - -- coroutine.wait(2) - -- effect:Dispose() - -- else - -- coroutine.wait(1.2) - -- effect:Dispose() - -- end - - -- end) +-- if type1 < 7 and type1 ~= 4 then return end +-- local eff_code = 0 +-- if type1 == 10 then --顺子 +-- eff_code = 2 +-- elseif type1 == 11 then --炸 +-- eff_code = 3 +-- elseif type1 == 4 then --连对 +-- eff_code = 4 +-- else +-- eff_code = 6 +-- end +-- local info = self._player_card_info[self:GetPos(player.seat)] +-- local pNode = info._mask_liangpai +-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/MovieClip" .. eff_code) + +-- effect.touchable = false + +-- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) +-- pNode:AddChild(effect) +-- if type1 == 10 then --顺子 +-- effect.x, effect.y = -400, -200 +-- elseif type1 == 11 then --炸 +-- effect.x, effect.y = -80, -225 +-- elseif type1 == 4 then --连对 +-- effect.x, effect.y = -400, -200 +-- else +-- effect.x, effect.y = -157, -140 +-- end +-- coroutine.start(function() +-- if type1== 10 or type1== 11 or type1== 4 then +-- -- body +-- coroutine.wait(2) +-- effect:Dispose() +-- else +-- coroutine.wait(1.2) +-- effect:Dispose() +-- end + +-- end) -- if eff_code ==3 then -- coroutine.start(function() -- coroutine.wait(1) @@ -1330,11 +1296,11 @@ function M:PlayCardEff(card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - printlog("DataManager.CurrenRoom.pai==11","ui://Extend_Poker_ShengSiDu/"..card) - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/"..card) + if DataManager.CurrenRoom.pai == 0 then + printlog("DataManager.CurrenRoom.pai==11", "ui://Extend_Poker_ShengSiDu/" .. card) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_ShengSiDu/" .. card) else - printlog("DataManager.CurrenRoom.pai==222","ui://Extend_Poker_ShengSiDu/"..card) + printlog("DataManager.CurrenRoom.pai==222", "ui://Extend_Poker_ShengSiDu/" .. card) card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") end card_code_obj:SetScale(1, 1) @@ -1353,10 +1319,9 @@ function M:PlayCardEff(card) end end) coroutine.wait(1) - --card_code_obj:Dispose() + --card_code_obj:Dispose() self._popEvent = true end) - end function M:ResetPoker() @@ -1367,8 +1332,7 @@ function M:ResetPoker() end function M:PlaySound(sex, path) - - local sex_path = ViewUtil.Sex_Chat[sex]-- 1 男 2 女 + local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 local sound_path = string.format("extend/poker/shengsidu/sound/%s/%s.mp3", sex_path, path) ViewUtil.PlaySound("ShengSiDu_PK", sound_path) end @@ -1381,11 +1345,12 @@ function M:ChangeBgmMusic(bgm_index) end ViewUtil.PlayMuisc("ShengSiDu_PK", string.format("extend/poker/shengsidu/sound/bgm%d.mp3", 1)) end -function M:OnPlayerEnter( ... ) - local arg = {...} + +function M:OnPlayerEnter(...) + local arg = { ... } local p = arg[1] - for i=1,#self._room.player_list do - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -1394,26 +1359,26 @@ function M:OnPlayerEnter( ... ) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end -- if p ~= self._room.self_player and self._room.room_config.people_num <= 4 and self._room.room_config.people_num >= 3 and self._gamectr:CheckGPS() then -- if self.distance_view then -- self.distance_view:Destroy() - -- end + -- end -- self.distance_view = PlayerDistanceView.new(true) -- self.distance_view:Show() -- end diff --git a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerBackView.lua b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerBackView.lua index a1a4e413..b5f40c15 100644 --- a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerBackView.lua +++ b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerBackView.lua @@ -20,15 +20,15 @@ local RunFast_Record_Event = { local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/shengsidu/bg/bg1', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg1'}, - {id = 2, url = 'extend/poker/shengsidu/bg/bg2', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg2'}, - {id = 3, url = 'extend/poker/shengsidu/bg/bg3', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg3'} + { id = 1, url = 'extend/poker/shengsidu/bg/bg1', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg1' }, + { id = 2, url = 'extend/poker/shengsidu/bg/bg2', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg2' }, + { id = 3, url = 'extend/poker/shengsidu/bg/bg3', thumb = 'ui://Extend_Poker_ShengSiDu/table_bg3' } } --- Create a new function M.new() - setmetatable(M, {__index = PKPlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKPlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'RunFast_PlayBackView' self:init() @@ -42,7 +42,8 @@ function M:InitView(url) end self._gamectr = ControllerManager.GetController(GameController) UIPackage.AddPackage('extend/poker/shengsidu/ui/Extend_Poker_ShengSiDu') - PKPlayBackView.InitView(self, 'ui://Extend_Poker_ShengSiDu/RunFast_Main_' .. self._room.room_config.people_num, default_bg, bg_config) + PKPlayBackView.InitView(self, 'ui://Extend_Poker_ShengSiDu/RunFast_Main_' .. self._room.room_config.people_num, + default_bg, bg_config) self._tex_round = self._view:GetChild('round') self._player_card_info = {} local _player_card_info = self._player_card_info @@ -54,8 +55,8 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) + + self._rightPanelView = RunFast_RightPanelView.new(self, rightpanel) rightpanel:GetChild("btn_setting").onClick:Clear() self._player_info = {} @@ -65,7 +66,7 @@ function M:InitView(url) _player_info[i] = PlayerInfoView.new(tem, self) end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -94,7 +95,7 @@ function M:NewPlayerPokerInfoView(view, index) end function M:FillRoomData(data) - print("hidezhanji 1111") + -- print("hidezhanji 1111") self._currentStep = 1 local room = DataManager.CurrenRoom local _player_card_info = self._player_card_info @@ -109,12 +110,12 @@ function M:FillRoomData(data) local head_info = self._player_info[self:GetPos(p.seat)] if p.total_hp then - print("hidezhanji 2222") + -- print("hidezhanji 2222") - head_info._view:GetChild('zhanji').visible=false + head_info._view:GetChild('zhanji').visible = false if room.hpOnOff == 1 or room:checkHpNonnegative() then - head_info._view:GetChild('zhanji').visible=true + head_info._view:GetChild('zhanji').visible = true head_info._view:GetChild('text_jifen').text = d2ad(p.total_hp) end end @@ -125,18 +126,17 @@ function M:FillRoomData(data) card_info:UpdateHandPoker(p.hand_list, false, true) end head_info:UpdatePiao(p.piao) - end self:UpdateRound() - + self:GenerateAllStepData(data) self:ShowStep(1) end function M:ShowStep(index) local step = self._step[index] - if step==nil then + if step == nil then return end for i = 1, #step.player_card_data do @@ -146,13 +146,12 @@ function M:ShowStep(index) p.hand_list = step.player_card_data[i].hand_list p.out_card_list = step.player_card_data[i].out_card_list p.hand_left_count = #p.hand_list - + if p.seat ~= self._room.self_player.seat then info:UpdateHandPoker(p.hand_list, false, true) else info:InitPoker(p.hand_list, false) end - end if step.cmd == RunFast_Record_Event.Evt_OutCard then @@ -194,7 +193,8 @@ function M:ShowStep(index) end if step.cmd == RunFast_Record_Event.Evt_Result then local Result = step.Result - self.result_view = RunFast_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, Result.winseat, 0, Result.remaincards) + self.result_view = RunFast_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, + Result.winseat, 0, Result.remaincards) local num = self._view:GetChildIndex(self._view:GetChild("panel_record")) self._view:AddChildAt(self.result_view._view, num) else @@ -257,6 +257,7 @@ function M:CmdPass(cmd, index) data.cmd = cmd.cmd data.current_out_seat = cmd.seat end + function M:Cmdresult(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd diff --git a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerSelfPokerInfoView.lua index 097a0783..65328d01 100644 --- a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_PlayerSelfPokerInfoView.lua @@ -17,7 +17,7 @@ local CardView = { local function NewCardView(card, cardcodenum, cardcodeflower) local self = {} - setmetatable(self, {__index = CardView}) + setmetatable(self, { __index = CardView }) self.btn_card = card self.card_code_number = cardcodenum self.card_code_flower = cardcodeflower @@ -38,8 +38,8 @@ local RunFast_PlayerSelfPokerInfoView = { local M = RunFast_PlayerSelfPokerInfoView function M.new(view, mainView) - setmetatable(M, {__index = RunFast_PlayerPokerInfoView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = RunFast_PlayerPokerInfoView }) + local self = setmetatable({}, { __index = M }) self._view = view self._mainView = mainView self.gameCtr = ControllerManager.GetController(GameController) @@ -88,7 +88,7 @@ function M:InitPoker(pokerList, isPlayAni, open) -- self.zhizhanplay=0 -- self.zhizhanzdts=0 local cs = 1.25 - if DataManager.CurrenRoom.cardsize==0 then + if DataManager.CurrenRoom.cardsize == 0 then cs = 1.35 elseif DataManager.CurrenRoom.cardsize == 1 then cs = 1.25 @@ -99,7 +99,7 @@ function M:InitPoker(pokerList, isPlayAni, open) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end - -- print(vardump(self.card_list)) + -- -- print(vardump(self.card_list)) self.cor_init_poker = nil self.card_list = {} @@ -107,73 +107,72 @@ function M:InitPoker(pokerList, isPlayAni, open) if isPlayAni == true then self.cor_init_poker = coroutine.start( - function() - self._mainView._popEvent = false - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) - end - table.sort(pokerList) + function() + self._mainView._popEvent = false + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) + end + table.sort(pokerList) - for i = 1, #pokerList do - local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) - local card_flower_code = pokerList[i] - local btn_card = self:CreatPoker(card_number_code, cs, open) - local x, y = self._view.width / 2 + 100, -200 - btn_card:SetXY(x, y) - btn_card.alpha = 0 - btn_card.touchable = false - -- coroutine.wait(0.05) - self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - self.card_list[#self.card_list + 1] = card_view + for i = 1, #pokerList do + local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) + local card_flower_code = pokerList[i] + local btn_card = self:CreatPoker(card_number_code, cs, open) + local x, y = self._view.width / 2 + 100, -200 + btn_card:SetXY(x, y) + btn_card.alpha = 0 + btn_card.touchable = false + -- coroutine.wait(0.05) + self.cards_view:AddChild(btn_card) + local card_view = NewCardView(btn_card, card_number_code, card_flower_code) + self.card_list[#self.card_list + 1] = card_view - table.sort(self.card_list, tableSortNumber) + table.sort(self.card_list, tableSortNumber) - if i == #pokerList then - for j = 1, #self.card_list do - local card = self.card_list[j] - card.btn_card.touchable = true - if open ~= 1 then - -- body - self:AddCardMoveEvent(card) + if i == #pokerList then + for j = 1, #self.card_list do + local card = self.card_list[j] + card.btn_card.touchable = true + if open ~= 1 then + -- body + self:AddCardMoveEvent(card) + end end end end - end - for j = #self.card_list, 1, -1 do - -- ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/mopai.mp3') - local card_view = self.card_list[j] - card_view.index = j - self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) + for j = #self.card_list, 1, -1 do + -- ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/mopai.mp3') + local card_view = self.card_list[j] + card_view.index = j + self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) - card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card:SetScale(value, value) - end - ) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card.alpha = value - end - ) - card_view.btn_card.alpha = 1 - end + card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card:SetScale(value, value) + end + ) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card.alpha = value + end + ) + card_view.btn_card.alpha = 1 + end - self._mainView._popEvent = true - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + self._mainView._popEvent = true + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + end end - end - ) + ) else - for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) local card_flower_code = pokerList[i] @@ -197,7 +196,6 @@ function M:InitPoker(pokerList, isPlayAni, open) end function M:updatePoker() - local templist = {} for i = 1, #self.card_list do templist[#templist + 1] = self.card_list[i].card_code_flower @@ -246,21 +244,21 @@ function M:AddCardMoveEvent(card) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -282,25 +280,25 @@ function M:AddCardMoveEvent(card) if card.btn_card.touchable == true then send_card[#send_card + 1] = card self:SetBtnCardColor(card, 1) - --print(vardump(card)) + ---- print(vardump(card)) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -340,6 +338,7 @@ function M:AddCardMoveEvent(card) end ) end + function M:zhizhanxuanpai() --智障选牌 -- body local temp_send_card = {} @@ -408,8 +407,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then + card.btn_card.x < max_x + then self:SetBtnCardColor(card, 0.8) if #send_card1 == 0 then -- body @@ -438,8 +437,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then + card.btn_card.x < max_x + then -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) -- card.card_isTouchable = 1 -- ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") @@ -460,7 +459,7 @@ function M:TouchMoving(context) end end end - --print(vardump(send_card1)) + ---- print(vardump(send_card1)) -- local send_card = {} -- self.send_card = {} -- for i = 1, #self.card_list do @@ -476,8 +475,8 @@ end function M:SetBtnCardColor(card, num) if card.btn_card:GetChildAt(0) ~= nil and card.btn_card:GetChildAt(0):GetChildAt(0) ~= nil and - card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil - then + card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil + then -- body card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(num, num, num) end @@ -601,13 +600,13 @@ function M:SetOutCardList(cardlist, isAnim) -- todo 出牌动画 local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - card.btn_card, - self.out_card_data['maxcount_x'], - 0.7 - ) + i, + #cardlist, + self.cards_view, + card.btn_card, + self.out_card_data['maxcount_x'], + 0.7 + ) card.btn_card:TweenMove(Vector2.New(pos.x, pos_y), time) -- self.tween = TweenUtils.TweenFloat(1, 0.7, time, function(x) -- card.btn_card:GetChildAt(0):SetScale(x, x) @@ -619,16 +618,16 @@ function M:SetOutCardList(cardlist, isAnim) end self.move_cor = coroutine.start( - function() - coroutine.wait(0.05) - for i = 1, #self.out_card_list do - local card = self.out_card_list[i] - self.cards_view:SetChildIndex(card, i - 1) + function() + coroutine.wait(0.05) + for i = 1, #self.out_card_list do + local card = self.out_card_list[i] + self.cards_view:SetChildIndex(card, i - 1) + end + coroutine.wait(0.1) + ViewUtil.PlaySound('ShengSiDu_PK', 'extend/poker/shengsidu/sound/chupai.mp3') end - coroutine.wait(0.1) - ViewUtil.PlaySound('ShengSiDu_PK', 'extend/poker/shengsidu/sound/chupai.mp3') - end - ) + ) else for i = 1, #cardlist do local poker_item = UIPackage.CreateObject('Extend_Poker_ShengSiDu', 'poker7') @@ -668,13 +667,13 @@ function M:SetOutCardList(cardlist, isAnim) self.cards_view:AddChild(poker_item) local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - poker_item, - self.out_card_data['maxcount_x'], - 1 - ) + i, + #cardlist, + self.cards_view, + poker_item, + self.out_card_data['maxcount_x'], + 1 + ) poker_item.xy = Vector2.New(pos.x, pos_y) self.out_card_list[#self.out_card_list + 1] = poker_item end @@ -754,10 +753,10 @@ function M:BtnEvent() end local send_card = {} self.send_card = {} - local currentCard={} + local currentCard = {} for i = 1, #self.card_list do local card = self.card_list[i] - table.insert(currentCard,card.card_code_flower) + table.insert(currentCard, card.card_code_flower) if card.btn_card.selected then send_card[#send_card + 1] = card.card_code_flower self.send_card[#self.send_card + 1] = card @@ -767,7 +766,7 @@ function M:BtnEvent() if #send_card == 0 then self:ErrorTip('请选择要出的牌 ') else - self.gameCtr:SendCard(send_card,currentCard) + self.gameCtr:SendCard(send_card, currentCard) end end ) @@ -848,6 +847,7 @@ function M:GetHandCardPos(index, card_count) x = start_x + (self.card_width + offset) * (index - 1) return Vector2.New(x, y) end + function M:GetHandCardPos1(index, card_count) local x, y = 0, -18 local offset = self:GetHandCardOffset(card_count) @@ -856,6 +856,7 @@ function M:GetHandCardPos1(index, card_count) x = start_x + (self.card_width + offset) * (index - 1) return x, y end + function M:ChangeOneCodeByFrom(card) local flower = math.floor(card / 100) local number = card % 100 @@ -872,13 +873,13 @@ function M:ErrorTip(error_text) self.cor_init_poker = nil self.cor_init_poker = coroutine.start( - function() - self.put_error_text.text = error_text - self.ctr_put_error.selectedIndex = 1 - coroutine.wait(2) - self.ctr_put_error.selectedIndex = 0 - end - ) + function() + self.put_error_text.text = error_text + self.ctr_put_error.selectedIndex = 1 + coroutine.wait(2) + self.ctr_put_error.selectedIndex = 0 + end + ) end --RunFast_CardType @@ -897,7 +898,7 @@ end function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) local tip_list = {} local sidaisan = false - local touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } local card_map, max_key = self:GetCardMapAndMaxKey(self.card_list) if type == RunFast_CardType.None then if DataManager.CurrenRoom.is_new_bout then @@ -959,9 +960,9 @@ function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) -- body sidaisan = true end - elseif type == RunFast_CardType.FourAndtOne then - printlog("四带一==>>>") - list_type, touch_type = self:CheckThreeAndTwo(card_map, number, length) + elseif type == RunFast_CardType.FourAndtOne then + printlog("四带一==>>>") + list_type, touch_type = self:CheckThreeAndTwo(card_map, number, length) end card_map, max_key = self:GetCardMapAndMaxKey(self.card_list) tip_list = self:GetMergeAllList(list_type, list_bomb) @@ -988,7 +989,7 @@ end -- 合并多个list function M:GetMergeAllList(...) - local lists = {...} + local lists = { ... } local merge_list = {} for i = 1, #lists do local list_item = lists[i] @@ -1016,7 +1017,7 @@ function M:CheckOneCard(pokerMap, num, length) end for k, v in pairs(pokerMap) do if k > num then - one_card_list[#one_card_list + 1] = {v[1]} + one_card_list[#one_card_list + 1] = { v[1] } touch_key_list[#touch_key_list + 1] = k end end @@ -1031,7 +1032,7 @@ function M:CheckOnePair(pokerMap, num, length) end for k, v in pairs(pokerMap) do -- 从三条和对子里面提取 if #v > 1 and k > num then - one_pair_list[#one_pair_list + 1] = {v[1], v[2]} + one_pair_list[#one_pair_list + 1] = { v[1], v[2] } touch_key_list[#touch_key_list + 1] = k end end @@ -1046,7 +1047,7 @@ function M:CheckThree(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v > 2 and k > num then - three_list[#three_list + 1] = {v[1], v[2], v[3]} + three_list[#three_list + 1] = { v[1], v[2], v[3] } touch_key_list[#touch_key_list + 1] = k end end @@ -1093,8 +1094,8 @@ function M:CheckThreeAndOne(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_one_list[#three_and_one_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_one_list[#three_and_one_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_one_list, touch_key_list @@ -1108,8 +1109,8 @@ function M:CheckThreeAndTwo(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_two_list[#three_and_two_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_two_list[#three_and_two_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_two_list, touch_key_list @@ -1194,7 +1195,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end if j == i + pair_length - 1 then plane_list[#plane_list + 1] = item_all_list - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end end @@ -1202,7 +1203,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end function M:SetNotTouchCard(touch_key_list, card_map) - local all_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local all_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } for i = 1, #all_key_list do local key = all_key_list[i] local isExsit = self:IsExistByList(touch_key_list, key) @@ -1245,13 +1246,14 @@ function M:GetCardMapAndMaxKey(pokerList) max_key = number end if map[number] == nil then - map[number] = {pokerList[i]} + map[number] = { pokerList[i] } else map[number][#map[number] + 1] = pokerList[i] end end return map, max_key end + function M:CheckOnes(pokerMap, num, length) local one_card_list = {} local touch_key_list = {} @@ -1269,7 +1271,7 @@ function M:CheckOnes(pokerMap, num, length) for i = 0, length - 1 do if l == k + i and l ~= 15 and l ~= 16 then -- body - text[#text + 1] = {p[1]} + text[#text + 1] = { p[1] } text2[#text2 + 1] = l if #text >= length then -- body @@ -1297,6 +1299,7 @@ function M:CheckOnes(pokerMap, num, length) end return one_card_list, touch_key_list, length end + function M:Clear() self:PlayScore(nil) self:SetOutCardInfo(nil, false) diff --git a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_RightPanelView.lua b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_RightPanelView.lua index 6a842d42..213713c6 100644 --- a/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_RightPanelView.lua +++ b/lua_probject/extend_project/extend/poker/shengsidu/ShengSiDu_RightPanelView.lua @@ -1,7 +1,7 @@ local MainRightPanelView = require("Game.View.MainRightPanelView") local RunFast_RightPanelView = {} local M = RunFast_RightPanelView -local function __init(self,mainView,view) +local function __init(self, mainView, view) local right_panel = view local btn_setting = right_panel:GetChild("btn_setting") @@ -22,17 +22,17 @@ local function __init(self,mainView,view) end end) else - print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) + -- print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) if mainView.dismiss_room_cd_time > 0 then GameApplication.Instance:ShowTips("您还处于解散冷却时间当中,请稍后重试!") else - _gamectr:AskDismissRoom() + _gamectr:AskDismissRoom() end end end) end) - self._tex_data = right_panel:GetChild("tex_data") + self._tex_data = right_panel:GetChild("tex_data") self._tex_time = right_panel:GetChild("tex_time") self._pb_batteryLevel = right_panel:GetChild("pb_batteryLevel") self._xinhao = right_panel:GetController("xinhao") @@ -50,21 +50,22 @@ local function __init(self,mainView,view) self._total_time = 0 self:__UpdateTime() - + -- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true) -- self._timer:Start() end -function RunFast_RightPanelView.new(mainView,view) - setmetatable(M, {__index = MainRightPanelView}) - local self = setmetatable({}, {__index = M}) - self.class = "RunFast_RightPanelView" - __init(self,mainView,view) +function RunFast_RightPanelView.new(mainView, view) + setmetatable(M, { __index = MainRightPanelView }) + local self = setmetatable({}, { __index = M }) + self.class = "RunFast_RightPanelView" + __init(self, mainView, view) return self end + function M:__UpdateTime() self._tex_data.text = os.date("%Y-%m-%d") self._tex_time.text = os.date("%H:%M") - if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then + if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then self._pb_batteryLevel.value = GameApplication.Instance:GetBatteryLevel() end @@ -74,7 +75,7 @@ function M:__UpdateTime() local ping = _client:getAveragePingTime() if not ping then return end ping = math.floor(ping / 2) - if ping > 300 then ping =300 end + if ping > 300 then ping = 300 end if ping <= 100 then self.ctr_xh.selectedIndex = 0 elseif ping <= 300 then @@ -85,4 +86,4 @@ function M:__UpdateTime() self._tex_ping.text = ping .. "ms" end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_MainView.lua b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_MainView.lua index f7387cf7..32c9edd9 100644 --- a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_MainView.lua +++ b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_MainView.lua @@ -12,8 +12,8 @@ local PlayerInfoView = import(".EXPlayerInfoView") local TableBG = import('Game.Data.TableBG') local M = {} function M.new() - setmetatable(M, {__index = PKMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKMainView }) + local self = setmetatable({}, { __index = M }) self.class = "TwoDouDiZhu_MainView" self:init() self._gamectr = ControllerManager.GetController(GameController) @@ -22,29 +22,30 @@ end local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/twodoudizhu/bg/bg1', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg1'}, - {id = 2, url = 'extend/poker/twodoudizhu/bg/bg2', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg2'}, - {id = 3, url = 'extend/poker/twodoudizhu/bg/bg3', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg3'} + { id = 1, url = 'extend/poker/twodoudizhu/bg/bg1', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg1' }, + { id = 2, url = 'extend/poker/twodoudizhu/bg/bg2', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg2' }, + { id = 3, url = 'extend/poker/twodoudizhu/bg/bg3', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg3' } } local GameState = { - ROOM_STATUS_INIT = 1, --初始化 - ROOM_STATUS_FAPAI = 2, --发牌 - ROOM_STATUS_JIAO_DIZHU = 3, --叫地主 - ROOM_STATUS_QIANG_DIZHU = 4, --抢地主 - ROOM_STATUS_CHUPAI = 5, --出牌中 - ROOM_STATUS_FINISH = 6, + ROOM_STATUS_INIT = 1, --初始化 + ROOM_STATUS_FAPAI = 2, --发牌 + ROOM_STATUS_JIAO_DIZHU = 3, --叫地主 + ROOM_STATUS_QIANG_DIZHU = 4, --抢地主 + ROOM_STATUS_CHUPAI = 5, --出牌中 + ROOM_STATUS_FINISH = 6, } function M:InitView(url) local room = self._room UIPackage.AddPackage("extend/poker/twodoudizhu/ui/Extend_Poker_TwoDouDiZhu") - printlog("============================",room.room_config.people_num) - PKMainView.InitView(self, "ui://Extend_Poker_TwoDouDiZhu/TwoDouDiZhu_Main_" .. room.room_config.people_num,nil,1,default_bg,bg_config,nil,"ui://Extend_Poker_TwoDouDiZhu/SettingWindow1") + printlog("============================", room.room_config.people_num) + PKMainView.InitView(self, "ui://Extend_Poker_TwoDouDiZhu/TwoDouDiZhu_Main_" .. room.room_config.people_num, nil, 1, + default_bg, bg_config, nil, "ui://Extend_Poker_TwoDouDiZhu/SettingWindow1") local _room = DataManager.CurrenRoom local user_id = DataManager.SelfUser.account_id - local json_data = Utils.LoadLocalFile(user_id.._room.game_id.."pai") + local json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "pai") if json_data == nil then local _gamectr = self._gamectr self._room.pai = 0 @@ -60,9 +61,9 @@ function M:InitView(url) self.threeBei.text = "0" self.threeBei1.text = "" self.three.visible = false - self:UpThree({0,0,0}) + self:UpThree({ 0, 0, 0 }) - json_data = Utils.LoadLocalFile(user_id.._room.game_id.."cardsize") + json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "cardsize") if json_data == nil then local _gamectr = self._gamectr self._room.cardsize = 1 @@ -81,7 +82,7 @@ function M:InitView(url) tem.visible = false end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -93,11 +94,10 @@ function M:InitView(url) if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - - self._rightPanelView = TwoDouDiZhu_RightPanelView.new(self, rightpanel) - for i=1,#self._room.player_list do - - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + + self._rightPanelView = TwoDouDiZhu_RightPanelView.new(self, rightpanel) + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -106,30 +106,30 @@ function M:InitView(url) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end - - if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then + + if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then -- body - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text=self._room.score_times .."倍" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = self._room.score_times .. "倍" else - self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text="" + self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = "" end - + self.ctr_state = self._view:GetController("state") self._ctr_action = self._view:GetController("action") self._tex_leftTime = self._view:GetChild("time"):GetChild("title") @@ -137,13 +137,13 @@ function M:InitView(url) self._text_round = self._view:GetChild("round") self.ctr_card_eff = self._view:GetController("card_eff") self._player_card_info = {} - + local _player_card_info = self._player_card_info for i = 1, room.room_config.people_num do local tem = self._view:GetChild("player_card_info_" .. i) _player_card_info[i] = self:NewPlayerCardInfoView(tem, i) end - + local list = room.player_list if not room.self_player.ready then self._ctr_action.selectedIndex = 1 @@ -160,42 +160,39 @@ function M:InitView(url) self:ReConnectForStart() end else - self._state.selectedIndex = StateType.Palying self:ReconnectForClearing() - end - --local tempdsaf=self._view:GetChild("btn_back_jiesan") - --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false - - self._view:GetChild("btn_back_jiesan").onClick:Set(function () + --local tempdsaf=self._view:GetChild("btn_back_jiesan") + --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) + --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false + + self._view:GetChild("btn_back_jiesan").onClick:Set(function() if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) - + self:ChangeBgmMusic() self:EventInit() - + self._view:GetChild("mask").onClick:Set(function() self:ResetPoker() end) local btn_rule = self._view:GetChild("right_panel"):GetChild("btn_log") self._view:GetChild('info_text'):GetChild('text').text = room.room_config:GetDes() - - if self._view:GetChild("shengyu")~=nil then + + if self._view:GetChild("shengyu") ~= nil then -- body - if room.room_config.Leaf==1 then + if room.room_config.Leaf == 1 then -- body - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余15张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余15张" else - self._view:GetChild("shengyu"):GetChild("shengyu").text="剩余16张" + self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余16张" end end @@ -210,7 +207,7 @@ function M:InitView(url) -- local feiCards = {101,102} -- if feiCards~= nil then -- for i=1,#feiCards do - -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..feiCards[i]) + -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..feiCards[i]) -- self.otherpoker_list:AddChild(card_code_obj) -- end -- end @@ -220,7 +217,7 @@ function M:InitView(url) -- self.test1 = self._view:GetChild("test1") -- self.test1.onClick:Set(function() - + -- self._player_card_info[1]:AddThree({101,102,103,408,307,207,208,106},{101,102,103}) -- end) -- printlog(" self.ctr_state.selectedIndex ", self.ctr_state.selectedIndex) @@ -232,32 +229,32 @@ function M:UpThree(cards) local Icon1 = self.three:GetChild("n0") local Icon2 = self.three:GetChild("n1") local Icon3 = self.three:GetChild("n2") - Icon1.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..cards[1] - Icon2.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..cards[2] - Icon3.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..cards[3] + Icon1.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_" .. cards[1] + Icon2.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_" .. cards[2] + Icon3.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_" .. cards[3] end function M:UpMul(mul) - self.threeBei.text = mul.."倍" + self.threeBei.text = mul .. "倍" self.three.visible = true end function M:UpMul1(mul) - if mul>1 then - self.threeBei1.text = mul.."倍" + if mul > 1 then + self.threeBei1.text = mul .. "倍" end end -function M:UpdateCard( index ) - self._room.pai=index +function M:UpdateCard(index) + self._room.pai = index local card_info = self._player_card_info[1] -- for i=1,#self._room.player_list do - -- print(i) + -- -- print(i) -- end card_info:updatePoker() for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + if self._room.curren_turn_seat ~= player.seat then if player.out_card_list[1] == 0 then player_card_info:SetOutCardInfo(nil, true) @@ -266,7 +263,7 @@ function M:UpdateCard( index ) end end end - if self.caozuo==1 then + if self.caozuo == 1 then local ctr_number = self.pass == nil and 2 or 1 local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) local cardType, cardNum, cardLength = self._gamectr:GetCardListInfo(lastCardList) @@ -279,12 +276,12 @@ function M:UpdateCard( index ) m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength,m) + self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength, m) end end function M:UpdateCardSize(index) - self._room.cardsize=index + self._room.cardsize = index local card_info = self._player_card_info[1] card_info:updatePoker() end @@ -298,7 +295,7 @@ end function M:OnPlayerEnter(...) MainView.OnPlayerEnter(self, ...) - local arg = {...} + local arg = { ... } local p = arg[1] local index = self:GetPos(p.seat) local info = self._player_info[index] @@ -313,7 +310,7 @@ function M:OnPlayerEnter(...) end function M:OnPlayerReady(...) - local arg = {...} + local arg = { ... } local p = arg[1] local _room = self._room local _player_info = self._player_info @@ -322,18 +319,18 @@ function M:OnPlayerReady(...) end local info = _player_info[self:GetPos(p.seat)] info:Ready(true) ---local readyNum = 0 ---for i = 1, #_room.player_list do --- local player = _room.player_list[i] --- if player.ready then readyNum = readyNum + 1 end ---end ---if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then --- if self._state.selectedIndex == 2 then --- local _gamectr = ControllerManager.GetController(GameController) --- _gamectr:StartGame() --- end --- --self._ctr_action.selectedIndex = 2 ---end + --local readyNum = 0 + --for i = 1, #_room.player_list do + -- local player = _room.player_list[i] + -- if player.ready then readyNum = readyNum + 1 end + --end + --if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then + -- if self._state.selectedIndex == 2 then + -- local _gamectr = ControllerManager.GetController(GameController) + -- _gamectr:StartGame() + -- end + -- --self._ctr_action.selectedIndex = 2 + --end end function M:OnPlayerLeave(...) @@ -346,7 +343,6 @@ function M:OnPlayerLeave(...) end end - function M:EventInit() local _gamectr = ControllerManager.GetController(GameController) MainView.EventInit(self) @@ -355,9 +351,9 @@ function M:EventInit() local _room = self._room _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnAlertJiaoDiZhu, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] - printlog("自己座位号+++++++++++++++++",self._room.self_player.seat) + printlog("自己座位号+++++++++++++++++", self._room.self_player.seat) if seat == self._room.self_player.seat then self._player_card_info[1]:ChangeSelfJiao(1) end @@ -367,7 +363,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnUserAlertQiangDiZhu, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] if seat == self._room.self_player.seat then self._player_card_info[1]:ChangeSelfJiao(2) @@ -376,10 +372,10 @@ function M:EventInit() card_info:ChangeJiao(-1) end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnUserJiaoDiZhu, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local jiao = arg[2] - local count = arg[3]--ChangeJiao + local count = arg[3] --ChangeJiao local curMul = arg[4] local card_info = self._player_card_info[self:GetPos(seat)] self:UpMul(curMul) @@ -389,39 +385,39 @@ function M:EventInit() local player1 = self._room:GetPlayerBySeat(seat) if (jiao == 0) then card_info:ChangeJiao(1) - self:PlaySound(player1.self_user.sex,"bujiao") + self:PlaySound(player1.self_user.sex, "bujiao") else card_info:ChangeJiao(3) - self:PlaySound(player1.self_user.sex,"jiaodizhu") + self:PlaySound(player1.self_user.sex, "jiaodizhu") end end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnUserQiangDiZhu, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local qiang = arg[2] local count = arg[3] local curMul = arg[6] local card_info = self._player_card_info[self:GetPos(seat)] self:UpMul(curMul) - self.tips.text = string.format(self.tipsContent,arg[4],arg[5]) + self.tips.text = string.format(self.tipsContent, arg[4], arg[5]) self.tips.visible = true if seat == self._room.self_player.seat then self._player_card_info[1]:ChangeSelfJiao(0) end local player1 = self._room:GetPlayerBySeat(seat) - + if (qiang == 0) then card_info:ChangeJiao(2) - self:PlaySound(player1.self_user.sex,"buqiang") + self:PlaySound(player1.self_user.sex, "buqiang") else card_info:ChangeJiao(4) - self:PlaySound(player1.self_user.sex,"qiangdizhu") + self:PlaySound(player1.self_user.sex, "qiangdizhu") end end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnDiZhuInfo, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local cards = arg[2] local mul = arg[3] @@ -436,10 +432,10 @@ function M:EventInit() end self:UpThree(cards) local _player_card_info = self._player_card_info - for i = 1, self._room.room_config.people_num do - self._player_card_info[i]:ChangeJiao(-1) + for i = 1, self._room.room_config.people_num do + self._player_card_info[i]:ChangeJiao(-1) end - if (self.dizhuSeat==self._room.self_player.seat) then + if (self.dizhuSeat == self._room.self_player.seat) then self.tipsContent = "你让[color=#ff0000]%s[/color]张牌,对手再出[color=#ff0000]%s[/color]张牌可胜利" else self.tipsContent = "你被让[color=#ff0000]%s[/color]张牌,你再出[color=#ff0000]%s[/color]张牌可胜利" @@ -447,13 +443,13 @@ function M:EventInit() end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnRangXian, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local rangCount = arg[2] local curMul = arg[3] local leftCount = arg[4] self:UpMul(curMul) - self.tips.text = string.format(self.tipsContent,rangCount,leftCount) + self.tips.text = string.format(self.tipsContent, rangCount, leftCount) -- if (seat==self._room.self_player.seat) then -- self.tipsContent = "你让[color=#ff0000]%s[/color]张牌,对手再出[color=#ff0000]%s[/color]张牌可胜利" -- else @@ -462,19 +458,19 @@ function M:EventInit() end) - + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnMingCard, function(...) - local arg = {...} + local arg = { ... } local card = arg[1] self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 1 self:PlayCardEff(card) end) - + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnInitCard, function(...) self.three.visible = false - local arg = {...} + local arg = { ... } local round = arg[1] local cardlist = arg[2] @@ -484,20 +480,20 @@ function M:EventInit() self.result_view:Destroy() self.result_view = nil end - + self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -510,44 +506,40 @@ function M:EventInit() for i = 1, #list do local p = list[i] local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..p.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" end p:Clear() head_info:FillData(p) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - + if p.seat == self._room.self_player.seat then - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body - card_info:InitPoker(cardlist,true,1) + card_info:InitPoker(cardlist, true, 1) else - card_info:InitPoker(cardlist,true) + card_info:InitPoker(cardlist, true) end - else --card_info:UpdateHandPoker(#cardlist,true,false) --todo --card_info:UpdateRemainCard(#cardlist,true) end end end) - - + + -- _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.Oener,function ( ... ) -- local arg = {...} -- local seat = arg[1] @@ -555,11 +547,11 @@ function M:EventInit() -- head_info._view:GetController("Oener").selectedIndex=1 -- end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnIndexMove, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local isNewBout = arg[2] local index = self:GetPos(seat) - + self.ctr_time.selectedIndex = index -- for i=1,#self._player_info do -- if index==i then @@ -571,16 +563,16 @@ function M:EventInit() -- head_info:MarkBank(false) -- end -- end - + if index == 1 then local card_info = self._player_card_info[index] card_info:SetOutCardInfo(nil, false) - -- if self.MypokerList ~= nil then - -- -- body - -- card_info:Clear() - -- card_info:InitPoker(self.MypokerList, false) - -- self.MypokerList = nil - -- end + -- if self.MypokerList ~= nil then + -- -- body + -- card_info:Clear() + -- card_info:InitPoker(self.MypokerList, false) + -- self.MypokerList = nil + -- end end self._left_time = 20 if self._room.ming_card ~= nil then @@ -592,9 +584,9 @@ function M:EventInit() end end end) - + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnBombScore, function(...) - local arg = {...} + local arg = { ... } local scoreList = arg[1] -- for i = 1, #scoreList do -- local player = self._room:GetPlayerBySeat(i) @@ -604,9 +596,9 @@ function M:EventInit() -- head_info:UpdateScore(player.total_score) -- end end) - + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnPlaySucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] local card_number = arg[2] local cardstype = arg[3] @@ -616,22 +608,20 @@ function M:EventInit() local curMul = arg[9] self:UpMul(curMul) self.ctr_time.selectedIndex = 0 - self.tips.text = string.format(self.tipsContent,arg[7],arg[8]) + self.tips.text = string.format(self.tipsContent, arg[7], arg[8]) self.tips.visible = true local index = self:GetPos(p.seat) - if index==1 then - self.caozuo=0 + if index == 1 then + self.caozuo = 0 end local head_info = self._player_info[index] - if head_info._view:GetChild("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil then -- body -- body - if card_number~=nil then + if card_number ~= nil then -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..card_number.."张" + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. card_number .. "张" end - - end local card_info = self._player_card_info[index] card_info:SetOutCardInfo(p.out_card_list, false, true) @@ -644,7 +634,7 @@ function M:EventInit() card_info:DeleteHandCards(p.out_card_list) else card_info:SetRemainCardNumber(card_number == 1) - --card_info:UpdateHandPoker(card_number,false,false) -- todo + --card_info:UpdateHandPoker(card_number,false,false) -- todo end if self._room.is_new_bout == true then for i = 1, #self._room.player_list do @@ -657,13 +647,13 @@ function M:EventInit() -- card_info:PlayCardTypeEff(cardstype) -- if cardstype~=12 then -- -- body - - + + -- if cardstype==10 and length>=6 then -- -- card_info_i -- local chuan = UIPackage.CreateObject("Extend_Poker_TwoDouDiZhu", "chuan1") -- local card_info_i = self._player_card_info[self:GetPos(p.seat)] - + -- card_info_i._mask_liangpai:AddChild(chuan) -- chuan:GetChild("n0").asMovieClip.playing = true -- ViewUtil.PlaySound("TwoDouDiZhu_PK", "extend/poker/paodekuai/sound/sunzi.mp3") @@ -673,7 +663,7 @@ function M:EventInit() -- -- body -- chuan:Dispose() -- end - + -- end) -- else @@ -681,9 +671,8 @@ function M:EventInit() -- end -- end self:_Effect(cardstype, p) - else - if cardstype == 11 and cardstype~=12 then + if cardstype == 11 and cardstype ~= 12 then self:_Effect(cardstype, p) end end @@ -700,16 +689,15 @@ function M:EventInit() self:PlaySound(p.self_user.sex, "card_1") end) end - end) - + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnPassSucc, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] - + self.ctr_time.selectedIndex = 0 local card_info = self._player_card_info[self:GetPos(p.seat)] - + --card_info:SetOutCardInfo(nil, false) if p.seat == self._room.self_player.seat and self.MypokerList ~= nil then -- body @@ -720,31 +708,30 @@ function M:EventInit() card_info:SetOutCardInfo(nil, true) self:PlaySound(p.self_user.sex, "buyao1") end) - + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnErrorTip, function(...) - local arg = {...} + local arg = { ... } local error_str = arg[1] self._player_card_info[1]:ErrorTip(error_str) -- self._player_card_info[1]:ResetPoker() end) - + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnPiaoTips, function(...) - local arg = {...} + local arg = { ... } local piao = arg[1] local reload = arg[2] if reload == 0 then - - if self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = cardlist end local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible=false - otherpoker_list:RemoveChildrenToPool() - end + + if otherpoker_list ~= nil then + -- body + otherpoker_list.visible = false + otherpoker_list:RemoveChildrenToPool() + end self.ctr_state.selectedIndex = 1 self.ctr_card_eff.selectedIndex = 0 if self.rank_view ~= nil then @@ -766,12 +753,12 @@ function M:EventInit() head_info:UpdatePiao(-1) end end - + self._player_card_info[1]:ShowPiao(piao) end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] @@ -779,7 +766,7 @@ function M:EventInit() end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnOptions, function(...) - local arg = {...} + local arg = { ... } local play = arg[1] local pass = arg[5] local card_type = arg[2] @@ -788,7 +775,7 @@ function M:EventInit() local rang = arg[6] local isCanPass = arg[7] local ctr_number = pass == nil and 2 or 1 - self.tips.text = string.format(self.tipsContent,arg[8],arg[9]) + self.tips.text = string.format(self.tipsContent, arg[8], arg[9]) self.tips.visible = true if isCanPass == 1 then ctr_number = 1 @@ -798,8 +785,8 @@ function M:EventInit() if (rang == 1) then ctr_number = 3 end - self.caozuo=1 --记录是否是自己出牌的阶段 - self.pass=pass + self.caozuo = 1 --记录是否是自己出牌的阶段 + self.pass = pass local m = false local next_seat = self._room.self_player.seat + 1 local card_info = self._player_card_info[1] @@ -817,19 +804,19 @@ function M:EventInit() m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length,m,play,zdts) + self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) end) - -- 托管 - _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.Game_TuoGuan, function(...) - local arg = {...} + -- 托管 + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.Game_TuoGuan, function(...) + local arg = { ... } local tuoguan = arg[1] local seat = arg[2] - + local tuoguanzhong = self._view:GetChild("tuoguanzhong") local zhezhao = self._view:GetChild("n109") local head_info = self._player_info[self:GetPos(seat)] if (tuoguan == 1) then - if (seat == self._room.self_player.seat ) then + if (seat == self._room.self_player.seat) then tuoguanzhong.visible = true -- tuoguanzhong.sortingOrder = 2 zhezhao.visible = true @@ -839,10 +826,10 @@ function M:EventInit() else head_info._view:GetController("tuoguan").selectedIndex = 1 end - -- if self.ispanguangzhe == true then - -- -- body - -- zhezhao.visible = false - -- end + -- if self.ispanguangzhe == true then + -- -- body + -- zhezhao.visible = false + -- end else if (seat == self._room.self_player.seat) then tuoguanzhong.visible = false @@ -858,8 +845,7 @@ function M:EventInit() end end) _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnResult, function(...) - - local arg = {...} + local arg = { ... } local over = arg[1] local info = arg[2] local win_seat = arg[3] @@ -878,12 +864,12 @@ function M:EventInit() if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end - - if remaincards then + + if remaincards then -- body - local newremaincards = _gamectr:ChangeCodeByFrom(remaincards,true) + local newremaincards = _gamectr:ChangeCodeByFrom(remaincards, true) table.sort(remaincards) for i = #newremaincards, 1, -1 do coroutine.start(function() @@ -893,27 +879,27 @@ function M:EventInit() local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_TwoDouDiZhu", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj = nil - if DataManager.CurrenRoom.pai==0 then - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if DataManager.CurrenRoom.pai == 0 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..card_n.."_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. + card_n .. "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..card_n) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. card_n) end - else - if card_n==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then + if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..card_n.."_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. + card_n .. "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end - end if card_code_obj ~= nil then card_code_obj:SetScale(0.6, 0.6) @@ -921,32 +907,27 @@ function M:EventInit() poker_item:AddChild(card_code_obj) otherpoker_list:AddChild(poker_item) end - end - end) - - end - end if self._cor_sound ~= nil then coroutine.stop(self._cor_sound) self._cor_sound = nil end - - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) + + if self.destory_win ~= nil then + coroutine.stop(self.destory_win) end if self.WinItem_view ~= nil then self.WinItem_view:Dispose() self.WinItem_view = nil end - + self.destory_win = nil self.destory_win = coroutine.start(function() - -- print("11111111111111") + -- -- print("11111111111111") -- coroutine.wait(1) if self:IsChunTian(info) then local url = "ui://Extend_Poker_TwoDouDiZhu/Spring" @@ -967,8 +948,7 @@ function M:EventInit() end --printlog("====================fanchun======================",self:IsChunTian(info),self:IsFanChun(info)) coroutine.wait(1) - if self._room.self_player.seat == win_seat then - + if self._room.self_player.seat == win_seat then -- local sprint_seat_list = self:GetSpringSeats(info) -- if #sprint_seat_list > 0 then -- local url = "ui://Extend_Poker_TwoDouDiZhu/Spring" @@ -979,27 +959,23 @@ function M:EventInit() -- ViewUtil.PlaySound("TwoDouDiZhu_PK", "base/common/sound/win new.mp3") -- end -- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_TwoDouDiZhu/Spring" or "ui://Extend_Poker_TwoDouDiZhu/Win_Mine" - - else local beigang = false - if #self:GetSpringSeats(info)>0 then - for i=1,#self:GetSpringSeats(info) do - if self:GetSpringSeats(info)[i]==self._room.self_player.seat then - -- local url = "ui://Extend_Poker_TwoDouDiZhu/spring2" + if #self:GetSpringSeats(info) > 0 then + for i = 1, #self:GetSpringSeats(info) do + if self:GetSpringSeats(info)[i] == self._room.self_player.seat then + -- local url = "ui://Extend_Poker_TwoDouDiZhu/spring2" -- self.WinItem_view = UIPackage.CreateObjectFromURL(url) -- self._view:AddChild(self.WinItem_view) -- self.WinItem_view:Center() -- self.WinItem_view:GetTransition("t0"):Play() - beigang=true + beigang = true end end - end -- if beigang == false then -- self:CreateRankEff() -- end - end for i = 1, #info do local player = info[i] @@ -1025,13 +1001,13 @@ function M:EventInit() rt = self._room.score_times end if over == 1 and self._room.hpOnOff == 1 then - head_info:UpdateScore(player.score / 10) --不可负分 + head_info:UpdateScore(player.score / 10) --不可负分 else head_info:UpdateScore(player.score * rt) end card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) end - + if player.seat ~= self._room.self_player.seat then card_info:UpdateHandPoker(player.cards, false, true) @@ -1041,14 +1017,15 @@ function M:EventInit() self:ChangeBgmMusic(1) -- if over == 0 then -- if #self:GetSpringSeats(info) > 0 then - -- -- print("222222222222222222") + -- -- -- print("222222222222222222") -- coroutine.wait(1) -- else - -- -- print("333333333333333333") + -- -- -- print("333333333333333333") -- -- coroutine.wait(2) -- end - - self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, remaincards,feiCards) + + self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, + remaincards, feiCards) self.result_view:Show() if self.WinItem_view ~= nil then self.WinItem_view:Dispose() @@ -1060,55 +1037,54 @@ function M:EventInit() end if self._room.self_player.entrust == true then - local btn_confirm = self.result_view._view:GetChild("btn_confirm") + local btn_confirm = self.result_view._view:GetChild("btn_confirm") btn_confirm.onClick:Call() end - -- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow") - -- _actionView.icon = "ui://Common/btn_comfirm" - -- _actionView.onClick:Set(function () - -- --local _gamectr = ControllerManager.GetController(GameController) - -- _gamectr:ConformToNextGame() - -- _actionView:Dispose() - -- end) - -- _actionView.xy = Vector2(900, 625) - -- self._view:AddChild(_actionView) - -- else - -- coroutine.wait(4) - -- self.result_view = TwoDouDiZhu_ResultView.new(self._root_view,info,self._room.room_id) - -- self.result_view:Show() - -- end + -- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow") + -- _actionView.icon = "ui://Common/btn_comfirm" + -- _actionView.onClick:Set(function () + -- --local _gamectr = ControllerManager.GetController(GameController) + -- _gamectr:ConformToNextGame() + -- _actionView:Dispose() + -- end) + -- _actionView.xy = Vector2(900, 625) + -- self._view:AddChild(_actionView) + -- else + -- coroutine.wait(4) + -- self.result_view = TwoDouDiZhu_ResultView.new(self._root_view,info,self._room.room_id) + -- self.result_view:Show() + -- end end) - if over==1 then + if over == 1 then -- body self:UnmarkSelfTuoguan() ControllerManager.ChangeController(LoddyController) - end self.threeBei.text = "0" self.threeBei1.text = "" self.three.visible = false - self:UpThree({0,0,0}) + self:UpThree({ 0, 0, 0 }) end) - - _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnResultByDissolve, function(...) - - local arg = {...} - local over = arg[1] - local info = arg[2] - local winseat = arg[3] - local dissolve = arg[4] - self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve,nil) - self.result_view:Show() - ControllerManager.ChangeController(LoddyController) - self:UnmarkSelfTuoguan() + _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnResultByDissolve, function(...) + local arg = { ... } + local over = arg[1] + local info = arg[2] + local winseat = arg[3] + local dissolve = arg[4] + + self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, + nil) + self.result_view:Show() + ControllerManager.ChangeController(LoddyController) + self:UnmarkSelfTuoguan() end) - + -- 确定开始下一局 成功 _gamectr:AddEventListener(TwoDouDiZhu_GameEvent.OnConfrimToNextGameSucc, function(...) - local arg = {...} + local arg = { ... } local aid = arg[1] local p = self._room:GetPlayerById(aid) if p.seat == self._room.self_player.seat then @@ -1132,10 +1108,10 @@ function M:EventInit() local otherpoker_list = self._view:GetChild("otherpoker_list") if otherpoker_list ~= nil then -- body - otherpoker_list.visible=false + otherpoker_list.visible = false otherpoker_list:RemoveChildrenToPool() end - --player_head._view:GetController("Oener").selectedIndex=0 + --player_head._view:GetController("Oener").selectedIndex=0 end end local player_info = self._player_info[self:GetPos(p.seat)] @@ -1144,12 +1120,11 @@ function M:EventInit() end function M:ReConnectForStart() - local _gamectr = ControllerManager.GetController(GameController) self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat) self._state.selectedIndex = 1 self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat) - + self:UpdateRound(self._room.curren_round) for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] @@ -1175,40 +1150,33 @@ function M:ReConnectForStart() end head_info:UpdateScore(player.total_score * rt) end - + head_info:UpdateLineState(player.line_state) head_info:UpdatePiao(player.piao) - - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - - if self._room.room_config.showlength==1 then + + + if self._room.room_config.showlength == 1 then -- body - head_info._view:GetController("shengyu").selectedIndex=1 + head_info._view:GetController("shengyu").selectedIndex = 1 else - head_info._view:GetController("shengyu").selectedIndex=0 + head_info._view:GetController("shengyu").selectedIndex = 0 end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - - + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" end if player.seat == self._room.self_player.seat then - if player.open ~= nil and player.open == 0 and self._room.room_config.people_num==3 and self._room.room_config.fangzuobi==1 then + if player.open ~= nil and player.open == 0 and self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then -- body self.MypokerList = player.hand_list player_card_info:InitPoker(player.hand_list, false, 1) - else - player_card_info:InitPoker(player.hand_list, false) end - else - player_card_info:SetRemainCardNumber(player.hand_count == 1) if player.hand_count == 1 then self.bgm_index = 2 @@ -1235,7 +1203,7 @@ function M:ReconnectForClearing() for _, player in ipairs(self._room.player_list) do local head_info = self._player_info[self:GetPos(player.seat)] local player_card_info = self._player_card_info[self:GetPos(player.seat)] - + --如果是体力值不可负分模式 则显示当前的hp值 if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) @@ -1261,74 +1229,69 @@ function M:ReconnectForClearing() head_info:UpdateLineState(player.line_state) --head_info._view:GetController("Oener").selectedIndex=0 head_info:UpdatePiao(player.piao) - if head_info._view:GetChild("shengyu")~=nil and head_info._view:GetController("shengyu")~=nil then + if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body - - if self._room.room_config.showlength==1 then - -- body - head_info._view:GetController("shengyu").selectedIndex=1 - else - head_info._view:GetController("shengyu").selectedIndex=0 - end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text="剩"..player.hand_count.."张" - - end - - - if player.seat == self._room.self_player.seat then + if self._room.room_config.showlength == 1 then + -- body + head_info._view:GetController("shengyu").selectedIndex = 1 + else + head_info._view:GetController("shengyu").selectedIndex = 0 + end + + -- body + head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. player.hand_count .. "张" + end + + + if player.seat == self._room.self_player.seat then player_card_info:InitPoker(player.hand_list, false) else player_card_info:UpdateHandPoker(player.hand_list, false, true) end if player.out_card_list[1] == 0 then - player_card_info:SetOutCardInfo(nil, false) else player_card_info:SetOutCardInfo(player.out_card_list, false) end end - win_seat=self._room.winseat + win_seat = self._room.winseat self._room.winseat = nil - + local remaincards = self._room.remaincards - if self._room.game_status==1 then - - + if self._room.game_status == 1 then -- body coroutine.start(function() coroutine.wait(0.3) - - self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat,0,nil) - self.result_view:Show() - local card_info = self._player_card_info[1] - card_info._view:GetChild("out_card_list").visible=true - end) - if remaincards then - local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards,true) - + self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, + win_seat, 0, nil) + self.result_view:Show() + local card_info = self._player_card_info[1] + card_info._view:GetChild("out_card_list").visible = true + end) + if remaincards then + local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards, true) + -- body local otherpoker_list = self._view:GetChild("otherpoker_list") - + if otherpoker_list ~= nil then -- body otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible=true + otherpoker_list.visible = true end for i = #newremaincards, 1, -1 do coroutine.start(function() coroutine.wait(0.1 * (15 - i)) - + local flow = newremaincards[i] % 10 local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num local poker_item = UIPackage.CreateObject("Extend_Poker_TwoDouDiZhu", "poker6") - + --local code = self:ChangeCodeByTo(card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") @@ -1343,13 +1306,13 @@ function M:ReconnectForClearing() -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..card_n.."_1") -- end --printlog("======================== ",card_n) - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..card_n) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. card_n) card_code_obj:SetScale(0.6, 0.6) poker_item:AddChild(card_code_obj) otherpoker_list:AddChild(poker_item) end) end - end + end end self:DuanXian() end @@ -1360,13 +1323,13 @@ function M:DuanXian() -- ROOM_STATUS_JIAO_DIZHU = 3, --叫地主 -- ROOM_STATUS_QIANG_DIZHU = 4, --抢地主 -- ROOM_STATUS_CHUPAI = 5, --出牌中 - -- ROOM_STATUS_FINISH = 6, - if (self._room.nineCards~=nil) then + -- ROOM_STATUS_FINISH = 6, + if (self._room.nineCards ~= nil) then end - if (self._room.threeCards~=nil) then + if (self._room.threeCards ~= nil) then end - if (self._room.gameStatus~=nil) then - if(self._room.gameStatus == GameState.ROOM_STATUS_INIT) then + if (self._room.gameStatus ~= nil) then + if (self._room.gameStatus == GameState.ROOM_STATUS_INIT) then elseif (self._room.gameStatus == GameState.ROOM_STATUS_FAPAI) then elseif (self._room.gameStatus == GameState.ROOM_STATUS_JIAO_DIZHU) then if self._room.gameSeat == self._room.self_player.seat then @@ -1385,7 +1348,7 @@ function M:DuanXian() self:UpMul1(self._room.threeCardMul) end end - if (self._room.nineCards~=nil) then + if (self._room.nineCards ~= nil) then end end @@ -1396,11 +1359,11 @@ function M:CreateRankEff() self.rank_view:GetTransition("t0"):Play() end -function M:_Effect( type1 ,player) +function M:_Effect(type1, player) -- body - - if type1 < 7 and type1 ~= 4 and type1 ~= 5 then - return + + if type1 < 7 and type1 ~= 4 and type1 ~= 5 then + return end local eff_code = 0 if type1 == 10 then @@ -1418,35 +1381,35 @@ function M:_Effect( type1 ,player) end local info = self._player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai - local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/eff_"..eff_code) + local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/eff_" .. eff_code) -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/eff2_1") effect.touchable = false effect:GetTransition("t0"):Play() -- effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - if eff_code==3 then + if eff_code == 3 then self._view:AddChild(effect) else pNode:AddChild(effect) end - - if eff_code==1 then + + if eff_code == 1 then self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/eff_feiji") self._view:AddChild(self.eff_feiji) self.eff_feiji:Center() self.eff_feiji:GetTransition("t0"):Play() end - if eff_code==3 then + if eff_code == 3 then effect:Center() else - if self:GetPos(player.seat)== 1 then - effect.x,effect.y = 0,24 + if self:GetPos(player.seat) == 1 then + effect.x, effect.y = 0, 24 else - effect.x,effect.y = 24,67 + effect.x, effect.y = 24, 67 end end - - + + -- effect:Center() -- if eff_code ==3 then -- coroutine.start(function() @@ -1456,53 +1419,54 @@ function M:_Effect( type1 ,player) -- else coroutine.start(function() coroutine.wait(1) - if self.eff_feiji~=nil then + if self.eff_feiji ~= nil then self.eff_feiji:Dispose() end effect:Dispose() end) -- end end + -- function M:_Effect(type1, player) - -- if type1 < 7 and type1 ~= 4 then return end - -- local eff_code = 0 - -- if type1 == 10 then --顺子 - -- eff_code = 2 - -- elseif type1 == 11 then --炸 - -- eff_code = 3 - -- elseif type1 == 4 then --连对 - -- eff_code = 4 - -- else - -- eff_code = 6 - -- end - -- local info = self._player_card_info[self:GetPos(player.seat)] - -- local pNode = info._mask_liangpai - -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/MovieClip" .. eff_code) - - -- effect.touchable = false - - -- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) - -- pNode:AddChild(effect) - -- if type1 == 10 then --顺子 - -- effect.x, effect.y = -400, -200 - -- elseif type1 == 11 then --炸 - -- effect.x, effect.y = -80, -225 - -- elseif type1 == 4 then --连对 - -- effect.x, effect.y = -400, -200 - -- else - -- effect.x, effect.y = -157, -140 - -- end - -- coroutine.start(function() - -- if type1== 10 or type1== 11 or type1== 4 then - -- -- body - -- coroutine.wait(2) - -- effect:Dispose() - -- else - -- coroutine.wait(1.2) - -- effect:Dispose() - -- end - - -- end) +-- if type1 < 7 and type1 ~= 4 then return end +-- local eff_code = 0 +-- if type1 == 10 then --顺子 +-- eff_code = 2 +-- elseif type1 == 11 then --炸 +-- eff_code = 3 +-- elseif type1 == 4 then --连对 +-- eff_code = 4 +-- else +-- eff_code = 6 +-- end +-- local info = self._player_card_info[self:GetPos(player.seat)] +-- local pNode = info._mask_liangpai +-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/MovieClip" .. eff_code) + +-- effect.touchable = false + +-- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) +-- pNode:AddChild(effect) +-- if type1 == 10 then --顺子 +-- effect.x, effect.y = -400, -200 +-- elseif type1 == 11 then --炸 +-- effect.x, effect.y = -80, -225 +-- elseif type1 == 4 then --连对 +-- effect.x, effect.y = -400, -200 +-- else +-- effect.x, effect.y = -157, -140 +-- end +-- coroutine.start(function() +-- if type1== 10 or type1== 11 or type1== 4 then +-- -- body +-- coroutine.wait(2) +-- effect:Dispose() +-- else +-- coroutine.wait(1.2) +-- effect:Dispose() +-- end + +-- end) -- if eff_code ==3 then -- coroutine.start(function() -- coroutine.wait(1) @@ -1553,10 +1517,10 @@ function M:IsChunTian(player_info) local chun = false for i = 1, #player_info do local player = player_info[i] - if player.chuntian then + if player.chuntian then chun = true break - end + end end return chun end @@ -1565,17 +1529,17 @@ function M:IsFanChun(player_info) local fanchun = false for i = 1, #player_info do local player = player_info[i] - if player.fanchun then + if player.fanchun then fanchun = true break - end + end end return fanchun end function M:GetSpringSeats(player_info) local seat_list = {} - local card_max_length = 17--self._room.room_config.Leaf + 14 + local card_max_length = 17 --self._room.room_config.Leaf + 14 for i = 1, #player_info do local player = player_info[i] if #player.cards == card_max_length then @@ -1600,10 +1564,10 @@ function M:PlayCardEff(card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") local card_code_obj - if DataManager.CurrenRoom.pai==0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..card) + if DataManager.CurrenRoom.pai == 0 then + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. card) else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") end card_code_obj:SetScale(1, 1) --poker_obj:AddChild(card_code_obj) @@ -1623,7 +1587,6 @@ function M:PlayCardEff(card) coroutine.wait(1) self._popEvent = true end) - end function M:ResetPoker() @@ -1634,8 +1597,7 @@ function M:ResetPoker() end function M:PlaySound(sex, path) - - local sex_path = ViewUtil.Sex_Chat[sex]-- 1 男 2 女 + local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 local sound_path = string.format("extend/poker/twodoudizhu/sound/%s/%s.mp3", sex_path, path) ViewUtil.PlaySound("TwoDouDiZhu_PK", sound_path) end @@ -1648,11 +1610,12 @@ function M:ChangeBgmMusic(bgm_index) end ViewUtil.PlayMuisc("TwoDouDiZhu_PK", string.format("extend/poker/twodoudizhu/sound/bgm%d.mp3", 1)) end -function M:OnPlayerEnter( ... ) - local arg = {...} + +function M:OnPlayerEnter(...) + local arg = { ... } local p = arg[1] - for i=1,#self._room.player_list do - if self._room.self_player.seat==self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then + for i = 1, #self._room.player_list do + if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip") local _action = self._view:AddChild(ErrorMsgTip) @@ -1661,26 +1624,26 @@ function M:OnPlayerEnter( ... ) local btn1 = _action:GetChild("btn_connect") local btn2 = _action:GetChild("btn_back") text.text = "您来晚了,座位有人,请重新进牌桌" - btn1.visible=false + btn1.visible = false btn2:Center() - btn2.y=btn2.y+50 + btn2.y = btn2.y + 50 btn2.onClick:Set(function() - -- body - ErrorMsgTip:Destroy() - ErrorMsgTip = nil - self._gamectr:LevelRoom(function(res) - ViewUtil.CloseModalWait() - NetResetConnectWindow.CloseNetReset() - ControllerManager.ChangeController(LoddyController) - ViewManager.ChangeView(ViewManager.View_Lobby) - end) + -- body + ErrorMsgTip:Destroy() + ErrorMsgTip = nil + self._gamectr:LevelRoom(function(res) + ViewUtil.CloseModalWait() + NetResetConnectWindow.CloseNetReset() + ControllerManager.ChangeController(LoddyController) + ViewManager.ChangeView(ViewManager.View_Lobby) + end) end) end end -- if p ~= self._room.self_player and self._room.room_config.people_num <= 4 and self._room.room_config.people_num >= 3 and self._gamectr:CheckGPS() then -- if self.distance_view then -- self.distance_view:Destroy() - -- end + -- end -- self.distance_view = PlayerDistanceView.new(true) -- self.distance_view:Show() -- end diff --git a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerBackView.lua b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerBackView.lua index 652138ee..fc4898ad 100644 --- a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerBackView.lua +++ b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerBackView.lua @@ -23,15 +23,15 @@ local TwoDouDiZhu_Record_Event = { local default_bg = 1 local bg_config = { - {id = 1, url = 'extend/poker/twodoudizhu/bg/bg1', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg1'}, - {id = 2, url = 'extend/poker/twodoudizhu/bg/bg2', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg2'}, - {id = 3, url = 'extend/poker/twodoudizhu/bg/bg3', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg3'} + { id = 1, url = 'extend/poker/twodoudizhu/bg/bg1', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg1' }, + { id = 2, url = 'extend/poker/twodoudizhu/bg/bg2', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg2' }, + { id = 3, url = 'extend/poker/twodoudizhu/bg/bg3', thumb = 'ui://Extend_Poker_TwoDouDiZhu/table_bg3' } } --- Create a new function M.new() - setmetatable(M, {__index = PKPlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PKPlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'TwoDouDiZhu_PlayBackView' self:init() @@ -45,7 +45,8 @@ function M:InitView(url) end self._gamectr = ControllerManager.GetController(GameController) UIPackage.AddPackage('extend/poker/twodoudizhu/ui/Extend_Poker_TwoDouDiZhu') - PKPlayBackView.InitView(self, 'ui://Extend_Poker_TwoDouDiZhu/TwoDouDiZhu_Main_' .. self._room.room_config.people_num, default_bg, bg_config) + PKPlayBackView.InitView(self, 'ui://Extend_Poker_TwoDouDiZhu/TwoDouDiZhu_Main_' .. self._room.room_config.people_num, + default_bg, bg_config) self._tex_round = self._view:GetChild('round') self._player_card_info = {} local _player_card_info = self._player_card_info @@ -61,8 +62,8 @@ function M:InitView(url) self.three = self._view:GetChild("three") self.threeBei = self.three:GetChild("n9") self.three.visible = false - - self._rightPanelView = TwoDouDiZhu_RightPanelView.new(self, rightpanel) + + self._rightPanelView = TwoDouDiZhu_RightPanelView.new(self, rightpanel) rightpanel:GetChild("btn_setting").onClick:Clear() self._player_info = {} @@ -72,7 +73,7 @@ function M:InitView(url) _player_info[i] = PlayerInfoView.new(tem, self) end local list = self._room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_info[self:GetPos(p.seat)] info._view.visible = true @@ -95,8 +96,6 @@ function M:InitView(url) self._cmdmap[TwoDouDiZhu_Record_Event.Evt_jiaoDiZhu] = self.CmdjiaoDiZhu self._cmdmap[TwoDouDiZhu_Record_Event.Evt_qiangDiZhu] = self.CmdqiangDiZhu self._cmdmap[TwoDouDiZhu_Record_Event.Evt_diZhuInfo] = self.CmddiZhuInfo - - end function M:NewPlayerPokerInfoView(view, index) @@ -107,7 +106,7 @@ function M:NewPlayerPokerInfoView(view, index) end function M:FillRoomData(data) - print("hidezhanji 1111") + -- print("hidezhanji 1111") self._currentStep = 1 local room = DataManager.CurrenRoom local _player_card_info = self._player_card_info @@ -122,12 +121,12 @@ function M:FillRoomData(data) local head_info = self._player_info[self:GetPos(p.seat)] if p.total_hp then - print("hidezhanji 2222") + -- print("hidezhanji 2222") - head_info._view:GetChild('zhanji').visible=false + head_info._view:GetChild('zhanji').visible = false if room.hpOnOff == 1 or room:checkHpNonnegative() then - head_info._view:GetChild('zhanji').visible=true + head_info._view:GetChild('zhanji').visible = true head_info._view:GetChild('text_jifen').text = d2ad(p.total_hp) end end @@ -138,18 +137,17 @@ function M:FillRoomData(data) card_info:UpdateHandPoker(p.hand_list, false, true) end head_info:UpdatePiao(p.piao) - end self:UpdateRound() - + self:GenerateAllStepData(data) self:ShowStep(1) end function M:ShowStep(index) local step = self._step[index] - if step==nil then + if step == nil then return end for i = 1, #step.player_card_data do @@ -159,13 +157,12 @@ function M:ShowStep(index) p.hand_list = step.player_card_data[i].hand_list p.out_card_list = step.player_card_data[i].out_card_list p.hand_left_count = #p.hand_list - + if p.seat ~= self._room.self_player.seat then info:UpdateHandPoker(p.hand_list, false, true) else info:InitPoker(p.hand_list, false) end - end -- Evt_jiaoDiZhu = 'jiaoDiZhu', @@ -191,30 +188,29 @@ function M:ShowStep(index) else card_info:ChangeJiao(3) end - end if step.cmd == TwoDouDiZhu_Record_Event.Evt_qiangDiZhu then local seat = step.seat local qiang = step.qiang - local card_info = self._player_card_info[self:GetPos(seat)] + local card_info = self._player_card_info[self:GetPos(seat)] if (qiang == 0) then card_info:ChangeJiao(2) else card_info:ChangeJiao(4) - end + end end if step.cmd == TwoDouDiZhu_Record_Event.Evt_diZhuInfo then local seat = step.seat - + local cards = step.cards local mul = step.mul self:UpMul(mul) local card_info = self._player_card_info[self:GetPos(seat)] - + self:UpThree(cards) local _player_card_info = self._player_card_info - for i = 1, self._room.room_config.people_num do - self._player_card_info[i]:ChangeJiao(-1) + for i = 1, self._room.room_config.people_num do + self._player_card_info[i]:ChangeJiao(-1) end end @@ -247,7 +243,8 @@ function M:ShowStep(index) end if step.cmd == TwoDouDiZhu_Record_Event.Evt_Result then local Result = step.Result - self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, Result.winseat, 0, Result.remaincards) + self.result_view = TwoDouDiZhu_ResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, + Result.winseat, 0, Result.remaincards) local num = self._view:GetChildIndex(self._view:GetChild("panel_record")) self._view:AddChildAt(self.result_view._view, num) else @@ -290,7 +287,7 @@ function M:CmdOutCard(cmd, index) u.card_list = cmd.data.card data.out_card_list = cmd.data.card_list printlog("card_listcard_list ") - pt(data.out_card_list) + pt(data.out_card_list) for i = 1, #data.out_card_list do local out_card = data.out_card_list[i] for j = 1, #u.hand_list do @@ -312,6 +309,7 @@ function M:CmdPass(cmd, index) data.cmd = cmd.cmd data.current_out_seat = cmd.seat end + function M:Cmdresult(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -329,8 +327,6 @@ function M:CmdResult(cmd, index) end end - - function M:CmdjiaoDiZhu(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -351,7 +347,6 @@ function M:CmddiZhuInfo(cmd, index) data.seat = cmd.data["seat"] data.cards = cmd.data["cards"] data.mul = cmd.data["mul"] - end function M:CopyLastStep(index) @@ -517,17 +512,16 @@ function M:Destroy() end function M:UpThree(cards) - local Icon1 = self.three:GetChild("n0") local Icon2 = self.three:GetChild("n1") local Icon3 = self.three:GetChild("n2") - Icon1.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..cards[1] - Icon2.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..cards[2] - Icon3.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_"..cards[3] + Icon1.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_" .. cards[1] + Icon2.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_" .. cards[2] + Icon3.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_poker_" .. cards[3] end function M:UpMul(mul) - self.threeBei.text = mul.."倍" + self.threeBei.text = mul .. "倍" self.three.visible = true end diff --git a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerSelfPokerInfoView.lua index 90211cce..0c6d0d18 100644 --- a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_PlayerSelfPokerInfoView.lua @@ -17,7 +17,7 @@ local CardView = { local function NewCardView(card, cardcodenum, cardcodeflower) local self = {} - setmetatable(self, {__index = CardView}) + setmetatable(self, { __index = CardView }) self.btn_card = card self.card_code_number = cardcodenum self.card_code_flower = cardcodeflower @@ -38,8 +38,8 @@ local TwoDouDiZhu_PlayerSelfPokerInfoView = { local M = TwoDouDiZhu_PlayerSelfPokerInfoView function M.new(view, mainView) - setmetatable(M, {__index = TwoDouDiZhu_PlayerPokerInfoView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = TwoDouDiZhu_PlayerPokerInfoView }) + local self = setmetatable({}, { __index = M }) self._view = view self._mainView = mainView self.gameCtr = ControllerManager.GetController(GameController) @@ -101,20 +101,20 @@ function M:ChongXuan() end function M:ChangeSelfJiao(index) - printlog("jiao ",index) + printlog("jiao ", index) self.jiao.selectedIndex = index end function M:AddThree(threeList) - for i = 1,#threeList do - table.insert(self.CurrenPokerList,threeList[i]) + for i = 1, #threeList do + table.insert(self.CurrenPokerList, threeList[i]) end --table.sort(self.CurrenPokerList) self:InitPoker(self.CurrenPokerList) self.card_list[#self.card_list + 1] = card_view - for i=1,#threeList do - for j = 1,#self.card_list do - if (threeList[i]==self.card_list[j].card_code_flower) then + for i = 1, #threeList do + for j = 1, #self.card_list do + if (threeList[i] == self.card_list[j].card_code_flower) then self:UpdateCardMove(self.card_list[j].btn_card, true, false) coroutine.start(function() coroutine.wait(1) @@ -124,7 +124,6 @@ function M:AddThree(threeList) end end end - end function M:InitPoker(pokerList, isPlayAni, open) @@ -139,7 +138,7 @@ function M:InitPoker(pokerList, isPlayAni, open) pt(pokerList) self.CurrenPokerList = {} local cs = 1.25 - if DataManager.CurrenRoom.cardsize==0 then + if DataManager.CurrenRoom.cardsize == 0 then cs = 1.35 elseif DataManager.CurrenRoom.cardsize == 1 then cs = 1.25 @@ -150,7 +149,7 @@ function M:InitPoker(pokerList, isPlayAni, open) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end - -- print(vardump(self.card_list)) + -- -- print(vardump(self.card_list)) self.cor_init_poker = nil self.card_list = {} @@ -158,74 +157,73 @@ function M:InitPoker(pokerList, isPlayAni, open) if isPlayAni == true then self.cor_init_poker = coroutine.start( - function() - self._mainView._popEvent = false - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) - end - table.sort(pokerList) + function() + self._mainView._popEvent = false + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) + end + table.sort(pokerList) - for i = 1, #pokerList do - local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) - local card_flower_code = pokerList[i] - printlog("card_number_code ",card_number_code," ","card_flower_code",card_flower_code) - local btn_card = self:CreatPoker(card_number_code, cs, open) - local x, y = self._view.width / 2 + 100, -200 - btn_card:SetXY(x, y) - btn_card.alpha = 0 - btn_card.touchable = false - -- coroutine.wait(0.05) - self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - self.card_list[#self.card_list + 1] = card_view + for i = 1, #pokerList do + local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) + local card_flower_code = pokerList[i] + printlog("card_number_code ", card_number_code, " ", "card_flower_code", card_flower_code) + local btn_card = self:CreatPoker(card_number_code, cs, open) + local x, y = self._view.width / 2 + 100, -200 + btn_card:SetXY(x, y) + btn_card.alpha = 0 + btn_card.touchable = false + -- coroutine.wait(0.05) + self.cards_view:AddChild(btn_card) + local card_view = NewCardView(btn_card, card_number_code, card_flower_code) + self.card_list[#self.card_list + 1] = card_view - table.sort(self.card_list, tableSortNumber) + table.sort(self.card_list, tableSortNumber) - if i == #pokerList then - for j = 1, #self.card_list do - local card = self.card_list[j] - card.btn_card.touchable = true - if open ~= 1 then - -- body - self:AddCardMoveEvent(card) + if i == #pokerList then + for j = 1, #self.card_list do + local card = self.card_list[j] + card.btn_card.touchable = true + if open ~= 1 then + -- body + self:AddCardMoveEvent(card) + end end end end - end - for j = #self.card_list, 1, -1 do - -- ViewUtil.PlaySound('TwoDouDiZhuNew_PK', 'extend/poker/TwoDouDiZhu/sound/mopai.mp3') - local card_view = self.card_list[j] - card_view.index = j - self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) + for j = #self.card_list, 1, -1 do + -- ViewUtil.PlaySound('TwoDouDiZhuNew_PK', 'extend/poker/TwoDouDiZhu/sound/mopai.mp3') + local card_view = self.card_list[j] + card_view.index = j + self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) - card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card:SetScale(value, value) - end - ) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card.alpha = value - end - ) - card_view.btn_card.alpha = 1 - end + card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card:SetScale(value, value) + end + ) + DSTween.To( + 0.7, + 1, + 0.1, + function(value) + card_view.btn_card.alpha = value + end + ) + card_view.btn_card.alpha = 1 + end - self._mainView._popEvent = true - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + self._mainView._popEvent = true + if self._mainView._rightPanelView._settingView ~= nil then + self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) + end end - end - ) + ) else - for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) local card_flower_code = pokerList[i] @@ -251,7 +249,6 @@ function M:InitPoker(pokerList, isPlayAni, open) end function M:updatePoker() - local templist = {} for i = 1, #self.card_list do templist[#templist + 1] = self.card_list[i].card_code_flower @@ -300,21 +297,21 @@ function M:AddCardMoveEvent(card) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -336,25 +333,25 @@ function M:AddCardMoveEvent(card) if card.btn_card.touchable == true then send_card[#send_card + 1] = card self:SetBtnCardColor(card, 1) - --print(vardump(card)) + ---- print(vardump(card)) if k == #self.card_list then if card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") end else if card.btn_card.x + - (self.card_width + self:GetHandCardOffset(#self.card_list)) > - min_x and - card.btn_card.x < max_x and - card.card_isTouchable == 0 - then + (self.card_width + self:GetHandCardOffset(#self.card_list)) > + min_x and + card.btn_card.x < max_x and + card.card_isTouchable == 0 + then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") + --ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") end end end @@ -394,6 +391,7 @@ function M:AddCardMoveEvent(card) end ) end + function M:zhizhanxuanpai() --智障选牌 -- body local temp_send_card = {} @@ -462,8 +460,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then + card.btn_card.x < max_x + then self:SetBtnCardColor(card, 0.8) if #send_card1 == 0 then -- body @@ -492,8 +490,8 @@ function M:TouchMoving(context) else if card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and - card.btn_card.x < max_x - then + card.btn_card.x < max_x + then -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) -- card.card_isTouchable = 1 -- ViewUtil.PlaySound("TwoDouDiZhuNew_PK", "extend/poker/paodekuai/sound/click.mp3") @@ -514,7 +512,7 @@ function M:TouchMoving(context) end end end - --print(vardump(send_card1)) + ---- print(vardump(send_card1)) -- local send_card = {} -- self.send_card = {} -- for i = 1, #self.card_list do @@ -530,8 +528,8 @@ end function M:SetBtnCardColor(card, num) if card.btn_card:GetChildAt(0) ~= nil and card.btn_card:GetChildAt(0):GetChildAt(0) ~= nil and - card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil - then + card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil + then -- body card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(num, num, num) end @@ -567,15 +565,15 @@ function M:ShowOutCardOption(ctr_select, type, number, length, mustPutMaxCard, p self.tips_click_count = 0 self.send_card = {} self.tips_card_list = self:GetCardTips(type, number, length, mustPutMaxCard) - + local x = {} - for i=1,#self.card_list do + for i = 1, #self.card_list do if (self.card_list[i].card_code_flower == 516 or self.card_list[i].card_code_flower == 617) then - table.insert(x,self.card_list[i]) + table.insert(x, self.card_list[i]) end end - if (#x>1) then - table.insert(self.tips_card_list,x) + if (#x > 1) then + table.insert(self.tips_card_list, x) end if #self.tips_card_list >= 1 then @@ -606,8 +604,6 @@ function M:ShowOutCardOption(ctr_select, type, number, length, mustPutMaxCard, p end self.ctr_put_card_option.selectedIndex = ctr_select --v[1].card_code_flower == 516 or v[1].card_code_flower == 617 - - end function M:ChangePutCardOption(ctr_select) @@ -672,13 +668,13 @@ function M:SetOutCardList(cardlist, isAnim) -- todo 出牌动画 local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - card.btn_card, - self.out_card_data['maxcount_x'], - 0.7 - ) + i, + #cardlist, + self.cards_view, + card.btn_card, + self.out_card_data['maxcount_x'], + 0.7 + ) card.btn_card:TweenMove(Vector2.New(pos.x, pos_y), time) -- self.tween = TweenUtils.TweenFloat(1, 0.7, time, function(x) -- card.btn_card:GetChildAt(0):SetScale(x, x) @@ -690,23 +686,23 @@ function M:SetOutCardList(cardlist, isAnim) end self.move_cor = coroutine.start( - function() - coroutine.wait(0.05) - for i = 1, #self.out_card_list do - local card = self.out_card_list[i] - self.cards_view:SetChildIndex(card, i - 1) + function() + coroutine.wait(0.05) + for i = 1, #self.out_card_list do + local card = self.out_card_list[i] + self.cards_view:SetChildIndex(card, i - 1) + end + coroutine.wait(0.1) + ViewUtil.PlaySound('TwoDouDiZhu_PK', 'extend/poker/twodoudizhu/sound/chupai.mp3') end - coroutine.wait(0.1) - ViewUtil.PlaySound('TwoDouDiZhu_PK', 'extend/poker/twodoudizhu/sound/chupai.mp3') - end - ) + ) else for i = 1, #cardlist do local poker_item = UIPackage.CreateObject('Extend_Poker_TwoDouDiZhu', 'poker7') local code = self:ChangeCodeByTo(cardlist[i]) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. code) local card_code_obj - printlog("code=========================",code) + printlog("code=========================", code) -- if DataManager.CurrenRoom.pai==0 then -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) -- else @@ -731,7 +727,7 @@ function M:SetOutCardList(cardlist, isAnim) -- card_code_obj = UIPackage.CreateObjectFromURL('ui://Main_Poker/' .. code .. '_2') -- end -- end - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/" .. code) if card_code_obj == nil then card_code_obj = UIPackage.CreateObjectFromURL('ui://Main_Poker/00') end @@ -741,13 +737,13 @@ function M:SetOutCardList(cardlist, isAnim) self.cards_view:AddChild(poker_item) local pos = self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - poker_item, - self.out_card_data['maxcount_x'], - 1 - ) + i, + #cardlist, + self.cards_view, + poker_item, + self.out_card_data['maxcount_x'], + 1 + ) poker_item.xy = Vector2.New(pos.x, pos_y) self.out_card_list[#self.out_card_list + 1] = poker_item end @@ -828,16 +824,15 @@ function M:BtnEvent() _curren_msg:Center() _curren_msg:GetChild('tex_message').text = '选择让先后再让对方3张牌,且对方先出牌,倍数翻倍' _curren_msg:GetChild('btn_ok').onClick:Set( - function() - self.ctr_put_card_option.selectedIndex = 0 + function() + self.ctr_put_card_option.selectedIndex = 0 self.gameCtr:SendUserRangXian() _curren_msg:Dispose() _curren_msg = nil - end ) _curren_msg:GetChild('btn_close').onClick:Set( - function() + function() _curren_msg:Dispose() _curren_msg = nil end @@ -852,10 +847,10 @@ function M:BtnEvent() end local send_card = {} self.send_card = {} - local currentCard={} + local currentCard = {} for i = 1, #self.card_list do local card = self.card_list[i] - table.insert(currentCard,card.card_code_flower) + table.insert(currentCard, card.card_code_flower) if card.btn_card.selected then send_card[#send_card + 1] = card.card_code_flower self.send_card[#self.send_card + 1] = card @@ -865,7 +860,7 @@ function M:BtnEvent() if #send_card == 0 then self:ErrorTip('请选择要出的牌 ') else - self.gameCtr:SendCard(send_card,currentCard) + self.gameCtr:SendCard(send_card, currentCard) end end ) @@ -884,7 +879,7 @@ function M:BtnEvent() -- self.btnQiang = self._view:GetChild("btnQiang") -- self.btnJiao = self._view:GetChild("btnJiao") - + self.btnChong.onClick:Set( function() self:ChongXuan() @@ -982,6 +977,7 @@ function M:GetHandCardPos(index, card_count) x = start_x + (self.card_width + offset) * (index - 1) return Vector2.New(x, y) end + function M:GetHandCardPos1(index, card_count) local x, y = 0, -18 local offset = self:GetHandCardOffset(card_count) @@ -990,6 +986,7 @@ function M:GetHandCardPos1(index, card_count) x = start_x + (self.card_width + offset) * (index - 1) return x, y end + function M:ChangeOneCodeByFrom(card) -- if card > 500 then -- return card @@ -1009,13 +1006,13 @@ function M:ErrorTip(error_text) self.cor_init_poker = nil self.cor_init_poker = coroutine.start( - function() - self.put_error_text.text = error_text - self.ctr_put_error.selectedIndex = 1 - coroutine.wait(2) - self.ctr_put_error.selectedIndex = 0 - end - ) + function() + self.put_error_text.text = error_text + self.ctr_put_error.selectedIndex = 1 + coroutine.wait(2) + self.ctr_put_error.selectedIndex = 0 + end + ) end --TwoDouDiZhu_CardType @@ -1034,7 +1031,7 @@ end function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) local tip_list = {} local sidaisan = false - local touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } local card_map, max_key = self:GetCardMapAndMaxKey(self.card_list) if type == TwoDouDiZhu_CardType.None then if DataManager.CurrenRoom.is_new_bout then @@ -1122,7 +1119,7 @@ end -- 合并多个list function M:GetMergeAllList(...) - local lists = {...} + local lists = { ... } local merge_list = {} for i = 1, #lists do local list_item = lists[i] @@ -1150,7 +1147,7 @@ function M:CheckOneCard(pokerMap, num, length) end for k, v in pairs(pokerMap) do if k > num then - one_card_list[#one_card_list + 1] = {v[1]} + one_card_list[#one_card_list + 1] = { v[1] } touch_key_list[#touch_key_list + 1] = k end end @@ -1165,7 +1162,7 @@ function M:CheckOnePair(pokerMap, num, length) end for k, v in pairs(pokerMap) do -- 从三条和对子里面提取 if #v > 1 and k > num then - one_pair_list[#one_pair_list + 1] = {v[1], v[2]} + one_pair_list[#one_pair_list + 1] = { v[1], v[2] } touch_key_list[#touch_key_list + 1] = k end end @@ -1180,7 +1177,7 @@ function M:CheckThree(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v > 2 and k > num then - three_list[#three_list + 1] = {v[1], v[2], v[3]} + three_list[#three_list + 1] = { v[1], v[2], v[3] } touch_key_list[#touch_key_list + 1] = k end end @@ -1227,8 +1224,8 @@ function M:CheckThreeAndOne(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_one_list[#three_and_one_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_one_list[#three_and_one_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_one_list, touch_key_list @@ -1242,8 +1239,8 @@ function M:CheckThreeAndTwo(pokerMap, num, length) end for k, v in pairs(pokerMap) do if #v >= 3 and k > num then - three_and_two_list[#three_and_two_list + 1] = {v[1], v[2], v[3]} - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + three_and_two_list[#three_and_two_list + 1] = { v[1], v[2], v[3] } + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end return three_and_two_list, touch_key_list @@ -1293,7 +1290,7 @@ function M:CheckBomb(pokerMap, num, length) end local daxiaowang = 0 for k, v in pairs(pokerMap) do - if #v == 4 and k > num then --- + if #v == 4 and k > num then --- bomb_list[#bomb_list + 1] = v touch_key_list[#touch_key_list + 1] = k end @@ -1329,7 +1326,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end if j == i + pair_length - 1 then plane_list[#plane_list + 1] = item_all_list - touch_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } end end end @@ -1337,7 +1334,7 @@ function M:CheckPlane(pokerMap, num, length, and_num) end function M:SetNotTouchCard(touch_key_list, card_map) - local all_key_list = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + local all_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } for i = 1, #all_key_list do local key = all_key_list[i] local isExsit = self:IsExistByList(touch_key_list, key) @@ -1380,13 +1377,14 @@ function M:GetCardMapAndMaxKey(pokerList) max_key = number end if map[number] == nil then - map[number] = {pokerList[i]} + map[number] = { pokerList[i] } else map[number][#map[number] + 1] = pokerList[i] end end return map, max_key end + function M:CheckOnes(pokerMap, num, length) local one_card_list = {} local touch_key_list = {} @@ -1404,7 +1402,7 @@ function M:CheckOnes(pokerMap, num, length) for i = 0, length - 1 do if l == k + i and l ~= 15 and l ~= 16 then -- body - text[#text + 1] = {p[1]} + text[#text + 1] = { p[1] } text2[#text2 + 1] = l if #text >= length then -- body @@ -1432,6 +1430,7 @@ function M:CheckOnes(pokerMap, num, length) end return one_card_list, touch_key_list, length end + function M:Clear() self:PlayScore(nil) self:SetOutCardInfo(nil, false) diff --git a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_RightPanelView.lua b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_RightPanelView.lua index 1cb9f26e..c8eab681 100644 --- a/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_RightPanelView.lua +++ b/lua_probject/extend_project/extend/poker/twodoudizhu/TwoDouDiZhu_RightPanelView.lua @@ -1,7 +1,7 @@ local MainRightPanelView = require("Game.View.MainRightPanelView") local TwoDouDiZhu_RightPanelView = {} local M = TwoDouDiZhu_RightPanelView -local function __init(self,mainView,view) +local function __init(self, mainView, view) local right_panel = view local btn_setting = right_panel:GetChild("btn_setting") @@ -22,17 +22,17 @@ local function __init(self,mainView,view) end end) else - print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) + -- print("mainView.dismiss_room_cd_time"..mainView.dismiss_room_cd_time) if mainView.dismiss_room_cd_time > 0 then GameApplication.Instance:ShowTips("您还处于解散冷却时间当中,请稍后重试!") else - _gamectr:AskDismissRoom() + _gamectr:AskDismissRoom() end end end) end) - self._tex_data = right_panel:GetChild("tex_data") + self._tex_data = right_panel:GetChild("tex_data") self._tex_time = right_panel:GetChild("tex_time") self._pb_batteryLevel = right_panel:GetChild("pb_batteryLevel") self._xinhao = right_panel:GetController("xinhao") @@ -50,21 +50,22 @@ local function __init(self,mainView,view) self._total_time = 0 self:__UpdateTime() - + -- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true) -- self._timer:Start() end -function TwoDouDiZhu_RightPanelView.new(mainView,view) - setmetatable(M, {__index = MainRightPanelView}) - local self = setmetatable({}, {__index = M}) - self.class = "TwoDouDiZhu_RightPanelView" - __init(self,mainView,view) +function TwoDouDiZhu_RightPanelView.new(mainView, view) + setmetatable(M, { __index = MainRightPanelView }) + local self = setmetatable({}, { __index = M }) + self.class = "TwoDouDiZhu_RightPanelView" + __init(self, mainView, view) return self end + function M:__UpdateTime() self._tex_data.text = os.date("%Y-%m-%d") self._tex_time.text = os.date("%H:%M") - if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then + if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then self._pb_batteryLevel.value = GameApplication.Instance:GetBatteryLevel() end @@ -74,7 +75,7 @@ function M:__UpdateTime() local ping = _client:getAveragePingTime() if not ping then return end ping = math.floor(ping / 2) - if ping > 300 then ping =300 end + if ping > 300 then ping = 300 end if ping <= 100 then self.ctr_xh.selectedIndex = 0 elseif ping <= 300 then @@ -85,4 +86,4 @@ function M:__UpdateTime() self._tex_ping.text = ping .. "ms" end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXGameController.lua b/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXGameController.lua index f4727e90..217d4b02 100644 --- a/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXGameController.lua +++ b/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXGameController.lua @@ -5,15 +5,15 @@ local M = {} --- Create a new HZ_GameController function M.new() - setmetatable(M,{__index = GameController}) - local self = setmetatable({}, {__index = M}) - self:init("常德跑胡子") - self.class = "RB_GameController" - return self + setmetatable(M, { __index = GameController }) + local self = setmetatable({}, { __index = M }) + self:init("常德跑胡子") + self.class = "RB_GameController" + return self end function M:init(name) - GameController.init(self,name) + GameController.init(self, name) self._eventmap[RB_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards self._eventmap[RB_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn @@ -31,50 +31,47 @@ function M:init(name) self._eventmap[RB_Protocol.GAME_EVT_RESULT1] = self.OneventResult1 self._eventmap[RB_Protocol.GAME_EVT_QIPAI] = self.OnEventQIPAI self._eventmap[RB_Protocol.GAME_EVT_ADD_CARD] = self.OnAddCard - self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai - self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim - - + self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai + self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim end function M:SendXiPaiAction(callBack) local _data = {} - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_XIPAI, _data) - self.XiPaiCallBack=callBack + self.XiPaiCallBack = callBack end function M:OnEventXiPai(evt_data) - if evt_data["result"]==0 then - if self.XiPaiCallBack then - self.XiPaiCallBack() - end - else - ViewUtil.ErrorTip(1000000,"申请洗牌失败") - end - + if evt_data["result"] == 0 then + if self.XiPaiCallBack then + self.XiPaiCallBack() + end + else + ViewUtil.ErrorTip(1000000, "申请洗牌失败") + end end function M:OnEventXiPaiAnim(evt_data) - printlog("洗牌动画===》》》》") - pt(evt_data) - local playeridList = evt_data["list"] - local isXiPai=false + printlog("洗牌动画===》》》》") + pt(evt_data) + local playeridList = evt_data["list"] + local isXiPai = false local otherisXiPai = false - if playeridList and #playeridList>0 then - for i=1,#playeridList do - local p = self._room:GetPlayerById(playeridList[i]) - if p== self._room.self_player then - isXiPai=true - else - otherisXiPai=true - end - end - end - - self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventXiPai,isXiPai,otherisXiPai) - end) + if playeridList and #playeridList > 0 then + for i = 1, #playeridList do + local p = self._room:GetPlayerById(playeridList[i]) + if p == self._room.self_player then + isXiPai = true + else + otherisXiPai = true + end + end + end + + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.EventXiPai, isXiPai, otherisXiPai) + end) end -- 发送出牌指令到服务器 @@ -82,23 +79,23 @@ function M:SendOutCard(card) local _data = {} _data["card"] = card local _room = self._room - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then _client:send(RB_Protocol.GAME_DIS_CARD, _data) end - end + --GAME_CHANGE_CARD GAME_DIS_CARD -function M:SendChangeCards( card_list ) +function M:SendChangeCards(card_list) local _data = {} - if card_list then - _data["card_list"] = card_list - else - _data["card_list"]={} - end - local _client = ControllerManager.GameNetClinet + if card_list then + _data["card_list"] = card_list + else + _data["card_list"] = {} + end + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) + _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) end end @@ -106,30 +103,29 @@ function M:SendChangeTypeFace(TypeFace) -- body local _data = {} _data["typeface"] = TypeFace - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) + _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) end end - -function M:ConformToNextGame( ) - local _client = ControllerManager.GameNetClinet +function M:ConformToNextGame() + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_EVT_CHUI) + _client:send(RB_Protocol.GAME_EVT_CHUI) end end -- 发送放子选择到服务器 -function M:SendAction(id,num) +function M:SendAction(id, num) local _data = {} _data["id"] = id - if num ~=nil then + if num ~= nil then _data["biid"] = num end local _client = ControllerManager.GameNetClinet - if _client ~= nil then - _client:send(RB_Protocol.GAME_ACTION, _data) + if _client ~= nil then + _client:send(RB_Protocol.GAME_ACTION, _data) end end @@ -139,25 +135,26 @@ function M:OnEventSendCards(evt_data) return end - local _room = self._room + local _room = self._room _room.curren_round = _room.curren_round + 1 if _room.curren_round > 0 then _room.playing = true end - local handcards = {} - if evt_data.card_list and #evt_data.card_list>0 then - handcards = evt_data["card_list"] - else - ViewUtil.ErrorTip(100000,"发牌数据异常") - end - + local handcards = {} + if evt_data.card_list and #evt_data.card_list > 0 then + handcards = evt_data["card_list"] + else + ViewUtil.ErrorTip(100000, "发牌数据异常") + end + local p = _room.self_player - local seat =nil - if evt_data.bank_seat then - seat = evt_data["bank_seat"] - else - ViewUtil.ErrorTip(100001,"发牌座位异常") - end _room.banker_seat = seat - for i=1,#_room.player_list do - _room.self_player.handcard_list ={} + local seat = nil + if evt_data.bank_seat then + seat = evt_data["bank_seat"] + else + ViewUtil.ErrorTip(100001, "发牌座位异常") + end + _room.banker_seat = seat + for i = 1, #_room.player_list do + _room.self_player.handcard_list = {} _room.self_player.card_list = {} _room.player_list[i].hand_left_count = 20 _room.player_list[i].fz_list = {} @@ -166,11 +163,11 @@ function M:OnEventSendCards(evt_data) _room.player_list[i].hu_xi = 0 end self._cacheEvent:Enqueue(function() - _room.self_player.handcard_list=handcards + _room.self_player.handcard_list = handcards self._room.self_player.hand_left_count = #handcards - DispatchEvent(self._dispatcher,RB_GameEvent.SendCards, p) - ControllerManager.IsSendCard=true - end) + DispatchEvent(self._dispatcher, RB_GameEvent.SendCards, p) + ControllerManager.IsSendCard = true + end) end function M:OnEventOutCard(evt_data) @@ -178,13 +175,13 @@ function M:OnEventOutCard(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(seat == _room.self_player.seat) then - list_remove(_room.self_player.handcard_list,card) + local _room = self._room + if (seat == _room.self_player.seat) then + list_remove(_room.self_player.handcard_list, card) end p.DiceCard = card - p.hand_left_count = p.hand_left_count -1 - DispatchEvent(self._dispatcher,RB_GameEvent.OutCard, p,card) + p.hand_left_count = p.hand_left_count - 1 + DispatchEvent(self._dispatcher, RB_GameEvent.OutCard, p, card) end) end @@ -193,10 +190,10 @@ function M:OnEventQIPAI(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(not p.outcard_list) then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card - DispatchEvent(self._dispatcher,RB_GameEvent.QiCard, seat,card) + local _room = self._room + if (not p.outcard_list) then p.outcard_list = {} end + p.outcard_list[#p.outcard_list + 1] = card + DispatchEvent(self._dispatcher, RB_GameEvent.QiCard, seat, card) end) end @@ -207,10 +204,10 @@ function M:OnEventTakeCard(evt_data) local left_count = evt_data["left_count"] local p = _room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - if card ~=0 then + if card ~= 0 then p.DiceCard = card end - DispatchEvent(self._dispatcher,RB_GameEvent.GetCard, seat, card, left_count) + DispatchEvent(self._dispatcher, RB_GameEvent.GetCard, seat, card, left_count) end) end @@ -219,55 +216,52 @@ function M:OnAddCard(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] local p = _room:GetPlayerBySeat(seat) - + self._cacheEvent:Enqueue(function() p.DiceCard = 0 - p.hand_left_count = p.hand_left_count +1 + p.hand_left_count = p.hand_left_count + 1 if (seat == _room.self_player.seat) then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - DispatchEvent(self._dispatcher,RB_GameEvent.AddCard, seat, card) + DispatchEvent(self._dispatcher, RB_GameEvent.AddCard, seat, card) end) end function M:OnEventOutHint(evt_data) - self._cacheEvent:Enqueue(function() - - DispatchEvent(self._dispatcher,RB_GameEvent.OutHint) + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.OutHint) end) - end function M:OnEventTurn(evt_data) local seat = evt_data["seat"] self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventTurn, seat) + DispatchEvent(self._dispatcher, RB_GameEvent.EventTurn, seat) end) end function M:OnEventFzTips(evt_data) self._cacheEvent:Enqueue(function() local tiplist = FZTipList.new() - local list = evt_data["tip_list"] - local uid = evt_data["uid"] - for i=1,#list do - local dtip = list[i] - local tip = {} - tip.id = dtip["id"] - tip.weight = dtip["weight"] - tip.card = dtip["card"] - tip.type = dtip["type"] - tip.bi_list = dtip["bi_list"] - if (dtip["opcard"]) then - local opcard = dtip["opcard"] - tip.OpCard = opcard - table.sort(tip.OpCard) - tip.OpCard[3] = tip.Card - end - tiplist:AddTip(tip) - + local list = evt_data["tip_list"] + local uid = evt_data["uid"] + for i = 1, #list do + local dtip = list[i] + local tip = {} + tip.id = dtip["id"] + tip.weight = dtip["weight"] + tip.card = dtip["card"] + tip.type = dtip["type"] + tip.bi_list = dtip["bi_list"] + if (dtip["opcard"]) then + local opcard = dtip["opcard"] + tip.OpCard = opcard + table.sort(tip.OpCard) + tip.OpCard[3] = tip.Card end - DispatchEvent(self._dispatcher,RB_GameEvent.FZTips, tiplist,uid) + tiplist:AddTip(tip) + end + DispatchEvent(self._dispatcher, RB_GameEvent.FZTips, tiplist, uid) end) end @@ -282,180 +276,172 @@ function M:OnEventFzAction(evt_data) local huxi = evt_data["hu_xi"] local p = _room:GetPlayerById(playerid) self._cacheEvent:Enqueue(function() - local isNeedDelHandCard =0 - p.hu_xi = huxi - local fz = {} - fz.card = card - fz.type = ftype - fz.active_card = actice_card - fz.from_seat = from_seat - fz.opcard =opcard - local remove_num = #opcard - if ftype == RB_FZType.Chi then - p.fz_list[#p.fz_list+1] = fz + local isNeedDelHandCard = 0 + p.hu_xi = huxi + local fz = {} + fz.card = card + fz.type = ftype + fz.active_card = actice_card + fz.from_seat = from_seat + fz.opcard = opcard + local remove_num = #opcard + if ftype == RB_FZType.Chi then + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Bi then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - list_remove(_room.self_player.handcard_list,fz.card) + list_remove(_room.self_player.handcard_list, fz.card) end elseif ftype == RB_FZType.Peng then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Kan then if (p == _room.self_player) then - if #opcard==2 then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + if #opcard == 2 then + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz end elseif ftype == RB_FZType.ChouWei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,2 do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, 2 do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Wei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Pao then - - if (p == _room.self_player) then - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) - end - end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Pao - end - end - local num =0 - for i=1,#_room.self_player.handcard_list do - if card == _room.self_player.handcard_list[i] then - num=num+1 - end - end - if num>0 then - isNeedDelHandCard =num - - for i=1,num do - list_remove(_room.self_player.handcard_list,card) - end - local isAddTi =false - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - isAddTi=true - remove_num= 0 - end - end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz - end - end - - else - local num =0 - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - num=1 - remove_num= 0 - end - end - if num==0 then - p.fz_list[#p.fz_list+1] = fz - end - end - - elseif ftype == RB_FZType.Ti then - if (p == _room.self_player) then - for i=1,#p.fz_list do + for i = 1, #p.fz_list do if p.fz_list[i].card == card then if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Ti + remove_num = 0 + p.fz_list[i].type = RB_FZType.Pao end end - local num =0 - for i=1,#_room.self_player.handcard_list do + local num = 0 + for i = 1, #_room.self_player.handcard_list do if card == _room.self_player.handcard_list[i] then - num=num+1 + num = num + 1 end end - if num>0 then - isNeedDelHandCard =num + if num > 0 then + isNeedDelHandCard = num - for i=1,num do - list_remove(_room.self_player.handcard_list,card) + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) end - local isAddTi =false - for i=1,#p.fz_list do + local isAddTi = false + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - isAddTi=true + p.fz_list[i].type = RB_FZType.Pao + isAddTi = true + remove_num = 0 end end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz end end - else - local num =0 - for i=1,#p.fz_list do + local num = 0 + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - num=1 + p.fz_list[i].type = RB_FZType.Pao + num = 1 + remove_num = 0 end end - if num==0 then - p.fz_list[#p.fz_list+1] = fz + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz end + end + elseif ftype == RB_FZType.Ti then + if (p == _room.self_player) then + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + if p.fz_list[i].type == RB_FZType.Kan then + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) + end + end + remove_num = 0 + p.fz_list[i].type = RB_FZType.Ti + end + end + local num = 0 + for i = 1, #_room.self_player.handcard_list do + if card == _room.self_player.handcard_list[i] then + num = num + 1 + end + end + if num > 0 then + isNeedDelHandCard = num - end - + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) + end + local isAddTi = false + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + isAddTi = true + end + end + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz + end + end + else + local num = 0 + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + num = 1 + end + end + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz + end + end end - + p.hand_left_count = p.hand_left_count - remove_num - if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then + if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then coroutine.start(function() coroutine.wait(0.5) - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) - end) - else - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) + end) + else + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) end - end) end @@ -463,12 +449,12 @@ function M:OnEventHu(evt_data) local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) - -- print(win_p.hand_left_count) - + -- -- print(win_p.hand_left_count) + self._cacheEvent:Enqueue(function() win_p.card_list = cards - table.sort( win_p.card_list, ViewUtil.HandCardSort) - DispatchEvent(self._dispatcher,RB_GameEvent.ZPHuCard, evt_data["seat"],evt_data["from_seat"],cards) + table.sort(win_p.card_list, ViewUtil.HandCardSort) + DispatchEvent(self._dispatcher, RB_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards) end) end @@ -484,17 +470,17 @@ function M:OneventResult1(evt_data) p.outcard_list = {} end self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult1, result); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult1, result); end) elseif 1 == over or 2 == over then DataManager.CurrenRoom.Over = true - ControllerManager.SetGameNetClient(nil,true) + ControllerManager.SetGameNetClient(nil, true) local total_result = evt_data.total_result local result = evt_data.result self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult2, result, total_result, over); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult2, result, total_result, over); end) end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXPlayBackView.lua b/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXPlayBackView.lua index 4ec205fc..922b0f5e 100644 --- a/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXPlayBackView.lua +++ b/lua_probject/extend_project/extend/zipai/changdepaohuzi/EXPlayBackView.lua @@ -21,8 +21,8 @@ end --- Create a new function M.new() - setmetatable(M, {__index = PlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'PlayBackView' self:init() @@ -137,15 +137,13 @@ function M:FillRoomData(data) infoHand:UpdateScore() end end - self.CheckServerErrorList={} + self.CheckServerErrorList = {} self:UpdateRound(self._room.curren_round) self:GenerateAllStepData(data) self:ShowStep(1) self:UpdateStep(1) end - - function M:ShowStep(index) local step = self._step[index + 1] self:UpdateStep(index + 1) @@ -181,21 +179,20 @@ function M:ShowStep(index) info:UpdateFzList(p.fz_list) end end - - if index>1 then - for k,v in pairs(self.CheckServerErrorList) do - --printlog("k===>>>",k) - --printlog("v===>>>",v) - --printlog(k,index) - --pt(p.card_list) - if tonumber(index+1)>tonumber(k) then - list_remove(p.card_list,v) - end - - end - end - - + + if index > 1 then + for k, v in pairs(self.CheckServerErrorList) do + --printlog("k===>>>",k) + --printlog("v===>>>",v) + --printlog(k,index) + --pt(p.card_list) + if tonumber(index + 1) > tonumber(k) then + list_remove(p.card_list, v) + end + end + end + + if p.seat ~= self._room.self_player.seat then info:InitHandCard(p.card_list) @@ -203,11 +200,11 @@ function M:ShowStep(index) self._room.self_player.handcard_list = p.card_list info:InitHandCard(false) end - - - - --if p.seat == self._room.self_player.seat then + + + + --if p.seat == self._room.self_player.seat then --[[if step.cmd == Record_Event.Evt_ChangePaiXing then local _card_list = {} for i = 1, #step.card_list do @@ -224,8 +221,8 @@ function M:ShowStep(index) info:UpdateHandCards(step.card_list) end end--]] - --end - + --end + if step.cmd == Record_Event.Evt_OutCard or step.cmd == Record_Event.Evt_GetCard then if step.DiceCard ~= nil and step.DiceCard ~= 0 then if p.seat == step.seat then @@ -243,7 +240,7 @@ function M:ShowStep(index) info:UpdateQiPai(p.outcard_list) end end - -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) + -- -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) if step.cmd == Record_Event.Evt_result then local _room = DataManager.CurrenRoom local result = step.result @@ -303,11 +300,11 @@ end function M:GenerateAllStepData(data) local cmdList = self.cmdList - --pt(cmdList) + --pt(cmdList) self._step = {} local step = {} local info = data.info - --pt(info) + --pt(info) step.cmd = '' step.left_card = info.left_card step.win = 0 @@ -350,6 +347,7 @@ function M:CmdGetCard(cmd, index) data.seat = cmd.seat data.DiceCard = cmd.data.card end + function M:CmdThrowCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -359,14 +357,15 @@ function M:CmdThrowCard(cmd, index) data.out_card_list = cmd.data.card u.outcard_list[#u.outcard_list + 1] = cmd.data.card end + function M:CmdAddCard(cmd, index) - --printlog("CmdAddCard======>>>",index,cmd.data.card) + --printlog("CmdAddCard======>>>",index,cmd.data.card) local data = self:CopyLastStep(index) data.cmd = cmd.cmd local _room = self._room local u = data.player_card_data[cmd.seat] u.card_list[#u.card_list + 1] = cmd.data.card - --pt(u.card_list) + --pt(u.card_list) end function M:onResult(cmd, index) @@ -458,11 +457,11 @@ function M:CmdAction(cmd, index) num = num + 1 end end - --table.insert(self.CheckServerErrorList,card) - if self.CheckServerErrorList==nil then - self.CheckServerErrorList={} - end - self.CheckServerErrorList[index]=card + --table.insert(self.CheckServerErrorList,card) + if self.CheckServerErrorList == nil then + self.CheckServerErrorList = {} + end + self.CheckServerErrorList[index] = card local isAddTi = false for i = 1, #p.fz_list do if p.fz_list[i].card == card then @@ -510,7 +509,7 @@ function M:CopyLastStep(index) card_data[i].hand_left_count = #card_data[i].card_list card_data[i].hu_xi = self:deepcopy(last_step.player_card_data[i].hu_xi) end - --pt(card_data) + --pt(card_data) self._step[#self._step + 1] = step return step end @@ -535,7 +534,7 @@ function M:deepcopy(object) end function M:NextRecordPlay() - printlog("NextRecordPlay") + printlog("NextRecordPlay") local result = PlayBackView.NextRecordPlay(self) if not result then return @@ -547,7 +546,7 @@ function M:NextRecordPlay() end function M:LastRecordPlay() - printlog("LastRecordPlay") + printlog("LastRecordPlay") local result = PlayBackView.LastRecordPlay(self) if not result then return diff --git a/lua_probject/extend_project/extend/zipai/changdepaohuzi/PlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/zipai/changdepaohuzi/PlayerSelfCardInfoView.lua index 245cf0d6..a8696fdc 100644 --- a/lua_probject/extend_project/extend/zipai/changdepaohuzi/PlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/zipai/changdepaohuzi/PlayerSelfCardInfoView.lua @@ -1,10 +1,10 @@ local PlayerSelfCardInfoView = require("main.zipai.ZPPlayerSelfCardInfoView") local CardCheck = require("main.zipai.CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(M, {__index = PlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(M, { __index = PlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -13,38 +13,36 @@ function M.new(view,mainView) return self end - function M:onTouchBegin(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local button = context.sender local card = button.data - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self:ShowHuTip(card.card_item) end - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", card.card_item) card.btn_card.sortingOrder = 100 - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - card.btn_card.xy = Vector2.New(card.btn_card.x+20 ,card.btn_card.y-50) + local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50) card.touch_pos = xy - button.xy - end function M:__OnDragEnd(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end local button = context.sender - + local card = button.data - + local _room = DataManager.CurrenRoom card.btn_card.sortingOrder = 0 - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y < -380 and _room.curren_outcard_seat == _room.self_player.seat) then button.touchable = false self.outcard_button = card @@ -53,7 +51,7 @@ function M:__OnDragEnd(context) else local isChangeCard = false self.outcard_button = nil - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_", card.card_item) self._area_handcard_list:AddChild(button) if #self.card_list == 1 then isChangeCard = false @@ -61,188 +59,184 @@ function M:__OnDragEnd(context) return end local CountCards = {} - for i=1,#self.card_list do + for i = 1, #self.card_list do local lists = {} if CountCards[self.card_list[i].index_X] == nil then - lists[#lists+1] = self.card_list[i] - CountCards[self.card_list[i].index_X]= lists + lists[#lists + 1] = self.card_list[i] + CountCards[self.card_list[i].index_X] = lists else - CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X]+1] =self.card_list[i] + CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X] + 1] = self.card_list[i] end end local minmark = 1 local maxmark = #self.card_list - if card == self.card_list[1] or card == self.card_list[#self.card_list] then + if card == self.card_list[1] or card == self.card_list[#self.card_list] then if self.card_list[1].index_X == self.card_list[2].index_X then - minmark =2 + minmark = 2 end - if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list-1].index_X then - maxmark =#self.card_list-1 + if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list - 1].index_X then + maxmark = #self.card_list - 1 end end - if button.x+button.width/2 < self.card_list[minmark].btn_card.x and #CountCards<10 then - list_remove(self.card_list,card) + if button.x + button.width / 2 < self.card_list[minmark].btn_card.x and #CountCards < 10 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X < card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X + 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X < card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X + 1 + end end else - for i=1,#self.card_list do - self.card_list[i].index_X = self.card_list[i].index_X + 1 + for i = 1, #self.card_list do + self.card_list[i].index_X = self.card_list[i].index_X + 1 end end - card.index_X =1 - card.index_Y =1 - table.insert(self.card_list,1,card) + card.index_X = 1 + card.index_Y = 1 + table.insert(self.card_list, 1, card) isChangeCard = true - elseif button.x+button.width/2 > (self.card_list[maxmark].btn_card.x +button.width) and #CountCards<10 then - list_remove(self.card_list,card) + elseif button.x + button.width / 2 > (self.card_list[maxmark].btn_card.x + button.width) and #CountCards < 10 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end end - card.index_X =self.card_list[#self.card_list].index_X+1 - card.index_Y =1 - self.card_list[#self.card_list+1] =card + card.index_X = self.card_list[#self.card_list].index_X + 1 + card.index_Y = 1 + self.card_list[#self.card_list + 1] = card isChangeCard = true - else + else local MoveCard = false local MoveCardPos = 0 local MoveCardY = 0 - for i=1,#CountCards do + for i = 1, #CountCards do local card_view = CountCards[i][1] - if card_view~=nil then - if button.x+button.width/2 > card_view.old_postion.x and button.x+button.width/2 < (card_view.old_postion.x+button.width) then - if card ~= card_view and #CountCards[i] <4 and card.index_X ~= card_view.index_X then - + if card_view ~= nil then + if button.x + button.width / 2 > card_view.old_postion.x and button.x + button.width / 2 < (card_view.old_postion.x + button.width) then + if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then MoveCardPos = i - MoveCardY = #CountCards[i]+1 + MoveCardY = #CountCards[i] + 1 MoveCard = true - list_remove(self.card_list,card) + list_remove(self.card_list, card) end end end end local MoveCardindex = 0 - -- local MoveCardY = 0 - if button.x+button.width/2 > card.old_postion.x and button.x+button.width/2 < (card.old_postion.x+button.width) then - if #CountCards[card.index_X]>1 then - for i=1,#CountCards[card.index_X] do + -- local MoveCardY = 0 + if button.x + button.width / 2 > card.old_postion.x and button.x + button.width / 2 < (card.old_postion.x + button.width) then + if #CountCards[card.index_X] > 1 then + for i = 1, #CountCards[card.index_X] do local _cv = CountCards[card.index_X][i] if _cv ~= card then - if button.y+button.height/2 > _cv.btn_card.y and button.y+button.height/2 < (_cv.btn_card.y+button.height) then + if button.y + button.height / 2 > _cv.btn_card.y and button.y + button.height / 2 < (_cv.btn_card.y + button.height) then --向下移動 - if ((button.y+button.height/2) +20) > (card.old_postion.y+button.height) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - --向上移動 - elseif ((button.y+button.height/2) -20) < card.old_postion.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - end - elseif i == #CountCards[card.index_X] and button.y+button.height/2 < _cv.btn_card.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - elseif i == 1 and button.y+button.height/2 > (_cv.btn_card.y+button.width) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) + if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + --向上移動 + elseif ((button.y + button.height / 2) - 20) < card.old_postion.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + end + elseif i == #CountCards[card.index_X] and button.y + button.height / 2 < _cv.btn_card.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + elseif i == 1 and button.y + button.height / 2 > (_cv.btn_card.y + button.width) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) end end end end - end - if MoveCard ==true and MoveCardindex ==0 then + if MoveCard == true and MoveCardindex == 0 then local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end if MoveCardPos > card.index_X then - MoveCardPos = MoveCardPos-1 + MoveCardPos = MoveCardPos - 1 end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do if MoveCardPos == self.card_list[i].index_X then - table.insert(self.card_list,(i+1),card) + table.insert(self.card_list, (i + 1), card) break end end isChangeCard = true - --上下移动 - elseif MoveCard ==true and MoveCardindex ~= 0 then - for i=1,#self.card_list do - if card.index_X == self.card_list[i].index_X then + --上下移动 + elseif MoveCard == true and MoveCardindex ~= 0 then + for i = 1, #self.card_list do + if card.index_X == self.card_list[i].index_X then --向下移动 if MoveCardindex == -1 then - if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then + if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then self.card_list[i].index_Y = self.card_list[i].index_Y + 1 - end - --向上移动 + --向上移动 else - if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 - + if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do - if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY-1) then - table.insert(self.card_list,(i+1),card) + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do + if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY - 1) then + table.insert(self.card_list, (i + 1), card) break - elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY+1) then - table.insert(self.card_list,i,card) + elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY + 1) then + table.insert(self.card_list, i, card) break end end @@ -251,176 +245,162 @@ function M:__OnDragEnd(context) isChangeCard = false self._area_handcard_list:AddChild(button) end - - end + end self:UpdateHandCardsPos() - if isChangeCard ==true then + if isChangeCard == true then self:SendChangeCard() end end end -function M:UpdateOutCardList(outcard,isShow,isMopai,seat) - if(isShow == nil) then - isShow = false +function M:UpdateOutCardList(outcard, isShow, isMopai, seat) + if (isShow == nil) then + isShow = false end - if(isMopai == nil) then - isMopai = false + if (isMopai == nil) then + isMopai = false end - self._area_outcard_list:RemoveChildren(0,-1,true) - local outcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") - - if outcard==0 then - outcards:GetChild("icon").icon ="ui://Main_RunBeard/202_1_300" + self._area_outcard_list:RemoveChildren(0, -1, true) + local outcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") + + if outcard == 0 then + outcards:GetChild("icon").icon = "ui://Main_RunBeard/202_1_300" else - outcards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/203_",outcard) + outcards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", outcard) end - outcards.x,outcards.y = 0,0 - local show_di_bg = outcards:GetChild("show_di_bg") + outcards.x, outcards.y = 0, 0 + local show_di_bg = outcards:GetChild("show_di_bg") --show_di_bg.visible = true - if(isShow)then - if outcard == 0 then - show_di_bg.visible = false - end - if(seat ~= nil and outcards~=nil)then - if(isMopai)then - if outcard ~= 0 then - outcards:GetTransition("mopai"..seat):Play(function( ) - -- show_di_bg.visible = true - - end) - end + if (isShow) then + if outcard == 0 then + show_di_bg.visible = false + end + if (seat ~= nil and outcards ~= nil) then + if (isMopai) then + if outcard ~= 0 then + outcards:GetTransition("mopai" .. seat):Play(function() + -- show_di_bg.visible = true + end) + end else - show_di_bg.visible = false - outcards:GetTransition("cpai"..seat):Play() + show_di_bg.visible = false + outcards:GetTransition("cpai" .. seat):Play() end - else - --show_di_bg.visible = true - end + else + --show_di_bg.visible = true + end else - show_di_bg.visible = false + show_di_bg.visible = false end self._area_outcard_list:AddChild(outcards) end --弃牌 -function M:UpdateQiPai( qi_list,isplay) - self._area_qipai_list:RemoveChildren(0,-1,true) - for i=1,#qi_list do - local qicards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") - qicards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/202_",qi_list[i]) - if(isplay)then - if(i == #qi_list) then - qicards:GetTransition("t0"):Play() +function M:UpdateQiPai(qi_list, isplay) + self._area_qipai_list:RemoveChildren(0, -1, true) + for i = 1, #qi_list do + local qicards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") + qicards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/202_", qi_list[i]) + if (isplay) then + if (i == #qi_list) then + qicards:GetTransition("t0"):Play() end - end - self._area_qipai_list:AddChild(qicards) - end + end + self._area_qipai_list:AddChild(qicards) + end end --摸牌动画 -function M:PlayingOutCardAnima( card) +function M:PlayingOutCardAnima(card) coroutine.start(function() - coroutine.wait(0.1) + coroutine.wait(0.1) self:ClearOutCard() end) end -function M:UpdateFzList( fz_list ,ispaly) - self._area_fz_list:RemoveChildren(0,-1,true) - for i = 1,#fz_list do - local fzitem=nil +function M:UpdateFzList(fz_list, ispaly) + self._area_fz_list:RemoveChildren(0, -1, true) + for i = 1, #fz_list do + local fzitem = nil if fz_list[i].type ~= RB_FZType.Kan then - fzitem =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") - if(ispaly == false)then - fzitem:RemoveChildren(0,-1,true) + fzitem = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") + if (ispaly == false) then + fzitem:RemoveChildren(0, -1, true) end end if fz_list[i].type == RB_FZType.Chi or fz_list[i].type == RB_FZType.Bi then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetChild("card_"..1).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].active_card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetChild("card_" .. 1).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].active_card) fzcards:GetController("c2").selectedIndex = 1 - fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[1]) - fzcards:GetChild("card_"..3).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[2]) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 2).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[1]) + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[2]) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Peng then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Wei then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetController("c1").selectedIndex=1 - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetController("c1").selectedIndex = 1 + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.ChouWei then - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,2 do - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 2 do + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end - fzcards:GetChild("card_"..3).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Pao then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Ti then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - if j==4 then - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + if j == 4 then + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) else - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) end end end - -function M:playAnim( fzitem,fzcards, size,i,ispaly ) - if(ispaly == nil)then - ispaly =false - end - if(ispaly and i == size)then - local faArray= fzitem:GetChild("chiwei") - if(faArray~=nil)then - faArray:AddChild(fzcards) - else - fzitem:AddChild(fzcards) - end - else - fzitem:AddChild(fzcards) - end - self._area_fz_list:AddChild(fzitem) +function M:playAnim(fzitem, fzcards, size, i, ispaly) + if (ispaly == nil) then + ispaly = false + end + if (ispaly and i == size) then + local faArray = fzitem:GetChild("chiwei") + if (faArray ~= nil) then + faArray:AddChild(fzcards) + else + fzitem:AddChild(fzcards) + end + else + fzitem:AddChild(fzcards) + end + self._area_fz_list:AddChild(fzitem) end - - --出牌提示动画 - function M:ChuPaiTiShi() - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then +--出牌提示动画 +function M:ChuPaiTiShi() + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local chu_player = DataManager.CurrenRoom.self_player @@ -431,32 +411,31 @@ end selfplayeTable.paoCount = chu_player.paoCount selfplayeTable.hu_xi = chu_player.hu_xi local player = membe_deep_clone(selfplayeTable) - local mark_ting= {} - for i=1,#DataManager.CurrenRoom.self_player.handcard_list do - local card = DataManager.CurrenRoom.self_player.handcard_list[i] + local mark_ting = {} + for i = 1, #DataManager.CurrenRoom.self_player.handcard_list do + local card = DataManager.CurrenRoom.self_player.handcard_list[i] list_remove(player.handcard_list, card) local _player = membe_deep_clone(player) - local tingList = CardCheck.tingPai(_player,DataManager.CurrenRoom) + local tingList = CardCheck.tingPai(_player, DataManager.CurrenRoom) local isKan = false - for j=1,#player.fz_list do + for j = 1, #player.fz_list do if card == player.fz_list[j].card and player.fz_list[j].type == RB_FZType.Kan then - isKan =true + isKan = true end end if #tingList > 0 and isKan == false then - - mark_ting[#mark_ting+1] = card + mark_ting[#mark_ting + 1] = card end table.insert(player.handcard_list, card) - table.sort( player.handcard_list, ViewUtil.HandCardSort) + table.sort(player.handcard_list, ViewUtil.HandCardSort) end - -- print("ChuPaiTiShi",#mark_ting,vardump(player)) - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then - self._view :GetController("chupai").selectedIndex =1 - if #mark_ting>0 then - for i=1,#mark_ting do - for k=1,#self.card_list do - local card_view= self.card_list[k] + -- -- print("ChuPaiTiShi",#mark_ting,vardump(player)) + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + self._view:GetController("chupai").selectedIndex = 1 + if #mark_ting > 0 then + for i = 1, #mark_ting do + for k = 1, #self.card_list do + local card_view = self.card_list[k] if card_view.card_item == mark_ting[i] then card_view.btn_card:GetController("mark_ting").selectedIndex = 1 end @@ -464,13 +443,12 @@ end end end else - self._view :GetController("chupai").selectedIndex =0 - for k=1,#self.card_list do - local card_view= self.card_list[k] + self._view:GetController("chupai").selectedIndex = 0 + for k = 1, #self.card_list do + local card_view = self.card_list[k] card_view.btn_card:GetController("mark_ting").selectedIndex = 0 - end end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/fulushou/EXGameController.lua b/lua_probject/extend_project/extend/zipai/fulushou/EXGameController.lua index cc6eb4ef..1049f524 100644 --- a/lua_probject/extend_project/extend/zipai/fulushou/EXGameController.lua +++ b/lua_probject/extend_project/extend/zipai/fulushou/EXGameController.lua @@ -5,15 +5,15 @@ local M = {} --- Create a new HZ_GameController function M.new() - setmetatable(M,{__index = GameController}) - local self = setmetatable({}, {__index = M}) - self:init("福禄寿") - self.class = "RB_GameController" - return self + setmetatable(M, { __index = GameController }) + local self = setmetatable({}, { __index = M }) + self:init("福禄寿") + self.class = "RB_GameController" + return self end function M:init(name) - GameController.init(self,name) + GameController.init(self, name) self._eventmap[RB_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards self._eventmap[RB_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn @@ -31,88 +31,75 @@ function M:init(name) self._eventmap[RB_Protocol.GAME_EVT_RESULT1] = self.OneventResult1 self._eventmap[RB_Protocol.GAME_EVT_QIPAI] = self.OnEventQIPAI --self._eventmap[RB_Protocol.GAME_EVT_ADD_CARD] = self.OnAddCard - - self._eventmap[RB_Protocol.GAME_EVT_Piao_Tip] = self.OnPiaoTip + + self._eventmap[RB_Protocol.GAME_EVT_Piao_Tip] = self.OnPiaoTip self._eventmap[RB_Protocol.GAME_EVT_Piao_Action] = self.OnPiaoAction - - self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai - self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim - - + + self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai + self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim end - - - function M:SendXiPaiAction(callBack) local _data = {} - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_XIPAI, _data) - self.XiPaiCallBack=callBack + self.XiPaiCallBack = callBack end function M:OnEventXiPai(evt_data) - if evt_data["result"]==0 then - if self.XiPaiCallBack then - self.XiPaiCallBack() - end - else - ViewUtil.ErrorTip(1000000,"申请洗牌失败") - end - + if evt_data["result"] == 0 then + if self.XiPaiCallBack then + self.XiPaiCallBack() + end + else + ViewUtil.ErrorTip(1000000, "申请洗牌失败") + end end - - - - function M:OnEventXiPaiAnim(evt_data) - printlog("洗牌动画===》》》》") - pt(evt_data) - local playeridList = evt_data["list"] - local my_isXiPai=false - local other_isXiPai=false - if playeridList and #playeridList>0 then - for i=1,#playeridList do - local p = self._room:GetPlayerById(playeridList[i]) - if p== self._room.self_player then - my_isXiPai=true - else - other_isXiPai=true - end - end - end - - self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventXiPai,my_isXiPai,other_isXiPai) - end) + printlog("洗牌动画===》》》》") + pt(evt_data) + local playeridList = evt_data["list"] + local my_isXiPai = false + local other_isXiPai = false + if playeridList and #playeridList > 0 then + for i = 1, #playeridList do + local p = self._room:GetPlayerById(playeridList[i]) + if p == self._room.self_player then + my_isXiPai = true + else + other_isXiPai = true + end + end + end + + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.EventXiPai, my_isXiPai, other_isXiPai) + end) end - - - -- 发送出牌指令到服务器 function M:SendOutCard(card) local _data = {} _data["card"] = card local _room = self._room - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then _client:send(RB_Protocol.GAME_DIS_CARD, _data) end - end + --GAME_CHANGE_CARD GAME_DIS_CARD -function M:SendChangeCards( card_list ) +function M:SendChangeCards(card_list) local _data = {} if card_list then - _data["card_list"] = card_list - else - _data["card_list"]={} - end - local _client = ControllerManager.GameNetClinet + _data["card_list"] = card_list + else + _data["card_list"] = {} + end + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) + _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) end end @@ -120,61 +107,56 @@ function M:SendChangeTypeFace(TypeFace) -- body local _data = {} _data["typeface"] = TypeFace - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) + _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) end end - -function M:ConformToNextGame( ) - local _client = ControllerManager.GameNetClinet +function M:ConformToNextGame() + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_EVT_CHUI) + _client:send(RB_Protocol.GAME_EVT_CHUI) end end -- 发送放子选择到服务器 -function M:SendAction(id,num) +function M:SendAction(id, num) local _data = {} _data["id"] = id - if num ~=nil then + if num ~= nil then _data["biid"] = num end local _client = ControllerManager.GameNetClinet - if _client ~= nil then - _client:send(RB_Protocol.GAME_ACTION, _data) + if _client ~= nil then + _client:send(RB_Protocol.GAME_ACTION, _data) end end - -function M:SendPiao(piao,callBack) +function M:SendPiao(piao, callBack) local _data = {} _data["id"] = piao local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_EVT_Send_Piao, _data) - self.PiaoTipsCallBack=callBack + self.PiaoTipsCallBack = callBack end - - - function M:OnPiaoTip(evt_data) if ViewManager.GetCurrenView().dview_class == LobbyView then self:ReturnToRoom() return end - printlog("飘分提示===>>>>") - pt(evt_data) + printlog("飘分提示===>>>>") + pt(evt_data) local piao = evt_data["piao"] local reload = evt_data["reload"] - local last_piao = evt_data["last_piao"] - local last_winer = evt_data["last_winer"] + local last_piao = evt_data["last_piao"] + local last_winer = evt_data["last_winer"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoTips, piao,reload,last_piao,last_winer) - ControllerManager.IsSendCard=true + DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoTips, piao, reload, last_piao, last_winer) + ControllerManager.IsSendCard = true end ) end @@ -182,50 +164,49 @@ end function M:OnPiaoAction(evt_data) local seat = evt_data["seat"] local piao = evt_data["piao"] - if seat==DataManager.CurrenRoom.self_player.seat then - if self.PiaoTipsCallBack then - self.PiaoTipsCallBack() - self.PiaoTipsCallBack=nil - end - end + if seat == DataManager.CurrenRoom.self_player.seat then + if self.PiaoTipsCallBack then + self.PiaoTipsCallBack() + self.PiaoTipsCallBack = nil + end + end self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoAction, seat,piao) + DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoAction, seat, piao) end ) end - function M:OnEventSendCards(evt_data) - printlog("发牌事件===》》》") - pt(evt_data) + printlog("发牌事件===》》》") + pt(evt_data) if ViewManager.GetCurrenView().dview_class == LobbyView then self:ReturnToRoom() return end - local _room = self._room + local _room = self._room _room.curren_round = _room.curren_round + 1 if _room.curren_round > 0 then _room.playing = true end - - local handcards = {} - if evt_data.card_list and #evt_data.card_list>0 then - handcards = evt_data["card_list"] - else - ViewUtil.ErrorTip(100000,"发牌数据异常") - end - + + local handcards = {} + if evt_data.card_list and #evt_data.card_list > 0 then + handcards = evt_data["card_list"] + else + ViewUtil.ErrorTip(100000, "发牌数据异常") + end + local p = _room.self_player - local seat =nil - if evt_data.bank_seat then - seat = evt_data["bank_seat"] - else - ViewUtil.ErrorTip(100001,"发牌座位异常") - end - + local seat = nil + if evt_data.bank_seat then + seat = evt_data["bank_seat"] + else + ViewUtil.ErrorTip(100001, "发牌座位异常") + end + _room.banker_seat = seat - for i=1,#_room.player_list do - _room.self_player.handcard_list ={} + for i = 1, #_room.player_list do + _room.self_player.handcard_list = {} _room.self_player.card_list = {} _room.player_list[i].hand_left_count = 18 _room.player_list[i].fz_list = {} @@ -234,113 +215,110 @@ function M:OnEventSendCards(evt_data) _room.player_list[i].hu_xi = 0 end self._cacheEvent:Enqueue(function() - _room.self_player.handcard_list=handcards + _room.self_player.handcard_list = handcards self._room.self_player.hand_left_count = #handcards - DispatchEvent(self._dispatcher,RB_GameEvent.SendCards, p) - print("发牌结束=====打开标志") - ControllerManager.IsSendCard=true - end) + DispatchEvent(self._dispatcher, RB_GameEvent.SendCards, p) + -- print("发牌结束=====打开标志") + ControllerManager.IsSendCard = true + end) end function M:OnEventOutCard(evt_data) - printlog("出牌===>>>") - pt(evt_data) + printlog("出牌===>>>") + pt(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] - + local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(seat == _room.self_player.seat) then - list_remove(_room.self_player.handcard_list,card) + local _room = self._room + if (seat == _room.self_player.seat) then + list_remove(_room.self_player.handcard_list, card) end p.DiceCard = card - p.hand_left_count = p.hand_left_count -1 - - if(not p.outcard_list) then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card - - DispatchEvent(self._dispatcher,RB_GameEvent.OutCard, p,card) - + p.hand_left_count = p.hand_left_count - 1 + + if (not p.outcard_list) then p.outcard_list = {} end + p.outcard_list[#p.outcard_list + 1] = card + + DispatchEvent(self._dispatcher, RB_GameEvent.OutCard, p, card) end) end function M:OnEventQIPAI(evt_data) - printlog("弃牌===>>>") + printlog("弃牌===>>>") local seat = evt_data["seat"] local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(not p.outcard_list) then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card - DispatchEvent(self._dispatcher,RB_GameEvent.QiCard, seat,card) + local _room = self._room + if (not p.outcard_list) then p.outcard_list = {} end + p.outcard_list[#p.outcard_list + 1] = card + DispatchEvent(self._dispatcher, RB_GameEvent.QiCard, seat, card) end) end function M:OnEventTakeCard(evt_data) - printlog("抓牌====>>>>") - pt(evt_data) - - self._room.self_player.CardTingList={} - self._room.self_player.allTingPaiList={} - self._room.self_player.tingPaiList=evt_data.ting_list - - if evt_data.ting_list and #evt_data.ting_list>0 then - local tempTingList={} - local tempCardTingList={} - for i=1,#DataManager.CurrenRoom.self_player.tingPaiList do - local tempCard=DataManager.CurrenRoom.self_player.tingPaiList[i].card - local tempV=DataManager.CurrenRoom.self_player.tingPaiList[i].value - tempCardTingList[tempCard]=tempV - if tempV and #tempV>0 then - for j=1,#tempV do - if IsHasDictionary(tempV[j],tempTingList)==false then - table.insert(tempTingList,tempV[j]) - end - end - end - end - if #tempTingList>0 then - DispatchEvent(self._dispatcher,RB_GameEvent.TuoGuanTipsEvt,true) - self._room.self_player.allTingPaiList=tempTingList - self._room.self_player.CardTingList=tempCardTingList - --pt(tempCardTingList) - end - else - DispatchEvent(self._dispatcher,RB_GameEvent.TuoGuanTipsEvt,false) - end - - ---------- - local _room = self._room + printlog("抓牌====>>>>") + pt(evt_data) + + self._room.self_player.CardTingList = {} + self._room.self_player.allTingPaiList = {} + self._room.self_player.tingPaiList = evt_data.ting_list + + if evt_data.ting_list and #evt_data.ting_list > 0 then + local tempTingList = {} + local tempCardTingList = {} + for i = 1, #DataManager.CurrenRoom.self_player.tingPaiList do + local tempCard = DataManager.CurrenRoom.self_player.tingPaiList[i].card + local tempV = DataManager.CurrenRoom.self_player.tingPaiList[i].value + tempCardTingList[tempCard] = tempV + if tempV and #tempV > 0 then + for j = 1, #tempV do + if IsHasDictionary(tempV[j], tempTingList) == false then + table.insert(tempTingList, tempV[j]) + end + end + end + end + if #tempTingList > 0 then + DispatchEvent(self._dispatcher, RB_GameEvent.TuoGuanTipsEvt, true) + self._room.self_player.allTingPaiList = tempTingList + self._room.self_player.CardTingList = tempCardTingList + --pt(tempCardTingList) + end + else + DispatchEvent(self._dispatcher, RB_GameEvent.TuoGuanTipsEvt, false) + end + + ---------- + local _room = self._room local seat = evt_data["seat"] local card = evt_data["card"] - local left_count = evt_data["left_count"] - local handcard_list=evt_data["card_list"] - local outcard_list=evt_data["outcard_list"] + local left_count = evt_data["left_count"] + local handcard_list = evt_data["card_list"] + local outcard_list = evt_data["outcard_list"] local p = _room:GetPlayerBySeat(seat) - p.hand_left_count = p.hand_left_count +1 - if seat == _room.self_player.seat then - self._cacheEvent:Enqueue(function() - if card ~=0 then - p.DiceCard = card - end - - if (seat == _room.self_player.seat) then - p.hand_left_count=#handcard_list - --_room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card - _room.self_player.handcard_list=handcard_list - end - - p.outcard_list=outcard_list - - DispatchEvent(self._dispatcher,RB_GameEvent.GetCard, seat, card,left_count) - end) - else - DispatchEvent(self._dispatcher,RB_GameEvent.ShowremainCard, seat,left_count) + p.hand_left_count = p.hand_left_count + 1 + if seat == _room.self_player.seat then + self._cacheEvent:Enqueue(function() + if card ~= 0 then + p.DiceCard = card + end + + if (seat == _room.self_player.seat) then + p.hand_left_count = #handcard_list + --_room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + _room.self_player.handcard_list = handcard_list + end + + p.outcard_list = outcard_list + + DispatchEvent(self._dispatcher, RB_GameEvent.GetCard, seat, card, left_count) + end) + else + DispatchEvent(self._dispatcher, RB_GameEvent.ShowremainCard, seat, left_count) end - - end function M:OnAddCard(evt_data) @@ -348,150 +326,144 @@ function M:OnAddCard(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] local p = _room:GetPlayerBySeat(seat) - + self._cacheEvent:Enqueue(function() p.DiceCard = 0 - p.hand_left_count = p.hand_left_count +1 + p.hand_left_count = p.hand_left_count + 1 if (seat == _room.self_player.seat) then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - DispatchEvent(self._dispatcher,RB_GameEvent.AddCard, seat, card) + DispatchEvent(self._dispatcher, RB_GameEvent.AddCard, seat, card) end) end function M:OnEventOutHint(evt_data) - printlog("出牌提示事件===》》》") - pt(evt_data) - self._cacheEvent:Enqueue(function() - - DispatchEvent(self._dispatcher,RB_GameEvent.OutHint) + printlog("出牌提示事件===》》》") + pt(evt_data) + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.OutHint) end) - end function M:OnEventTurn(evt_data) local seat = evt_data["seat"] self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventTurn, seat) + DispatchEvent(self._dispatcher, RB_GameEvent.EventTurn, seat) end) end function M:OnEventFzTips(evt_data) - printlog("放子提示事件===》》》") - pt(evt_data) + printlog("放子提示事件===》》》") + pt(evt_data) self._cacheEvent:Enqueue(function() local tiplist = FZTipList.new() - local list = evt_data["tip_list"] + local list = evt_data["tip_list"] --local uid = evt_data["uid"] - for i=1,#list do - local dtip = list[i] - local tip = {} - tip.id = dtip["id"] - tip.weight = dtip["weight"] - tip.card = dtip["card"] - tip.type = dtip["type"] - --tip.bi_list = dtip["bi_list"] - if (dtip["opcard"]) then - local opcard = dtip["opcard"] - tip.OpCard = opcard - table.sort(tip.OpCard) - tip.OpCard[3] = tip.Card - end - tiplist:AddTip(tip) - + for i = 1, #list do + local dtip = list[i] + local tip = {} + tip.id = dtip["id"] + tip.weight = dtip["weight"] + tip.card = dtip["card"] + tip.type = dtip["type"] + --tip.bi_list = dtip["bi_list"] + if (dtip["opcard"]) then + local opcard = dtip["opcard"] + tip.OpCard = opcard + table.sort(tip.OpCard) + tip.OpCard[3] = tip.Card end - DispatchEvent(self._dispatcher,RB_GameEvent.FZTips, tiplist) + tiplist:AddTip(tip) + end + DispatchEvent(self._dispatcher, RB_GameEvent.FZTips, tiplist) end) end function M:OnEventFzAction(evt_data) - printlog("放子行为事件===》》》") - pt(evt_data) - - - self._room.self_player.CardTingList={} - self._room.self_player.allTingPaiList={} - self._room.self_player.tingPaiList=evt_data.ting_list - - if evt_data.ting_list and #evt_data.ting_list>0 then - local tempTingList={} - local tempCardTingList={} - for i=1,#DataManager.CurrenRoom.self_player.tingPaiList do - local tempCard=DataManager.CurrenRoom.self_player.tingPaiList[i].card - local tempV=DataManager.CurrenRoom.self_player.tingPaiList[i].value - tempCardTingList[tempCard]=tempV - if tempV and #tempV>0 then - for j=1,#tempV do - if IsHasDictionary(tempV[j],tempTingList)==false then - table.insert(tempTingList,tempV[j]) - end - end - end - end - if #tempTingList>0 then - DispatchEvent(self._dispatcher,RB_GameEvent.TuoGuanTipsEvt,true) - self._room.self_player.allTingPaiList=tempTingList - self._room.self_player.CardTingList=tempCardTingList - --pt(tempCardTingList) - end - else - DispatchEvent(self._dispatcher,RB_GameEvent.TuoGuanTipsEvt,false) - end - - - --------- - + printlog("放子行为事件===》》》") + pt(evt_data) + + + self._room.self_player.CardTingList = {} + self._room.self_player.allTingPaiList = {} + self._room.self_player.tingPaiList = evt_data.ting_list + + if evt_data.ting_list and #evt_data.ting_list > 0 then + local tempTingList = {} + local tempCardTingList = {} + for i = 1, #DataManager.CurrenRoom.self_player.tingPaiList do + local tempCard = DataManager.CurrenRoom.self_player.tingPaiList[i].card + local tempV = DataManager.CurrenRoom.self_player.tingPaiList[i].value + tempCardTingList[tempCard] = tempV + if tempV and #tempV > 0 then + for j = 1, #tempV do + if IsHasDictionary(tempV[j], tempTingList) == false then + table.insert(tempTingList, tempV[j]) + end + end + end + end + if #tempTingList > 0 then + DispatchEvent(self._dispatcher, RB_GameEvent.TuoGuanTipsEvt, true) + self._room.self_player.allTingPaiList = tempTingList + self._room.self_player.CardTingList = tempCardTingList + --pt(tempCardTingList) + end + else + DispatchEvent(self._dispatcher, RB_GameEvent.TuoGuanTipsEvt, false) + end + + + --------- + local _room = self._room - _room.self_player.currentNotPutCardList=evt_data["notput"] + _room.self_player.currentNotPutCardList = evt_data["notput"] local playerid = evt_data["playerid"] local card = evt_data["card"] local ftype = evt_data["type"] local from_seat = evt_data["from_seat"] local opcard = evt_data["opcard"] - local outcard_list=evt_data["outcard_list"] + local outcard_list = evt_data["outcard_list"] local huxi = evt_data["hu_xi"] local actice_card = membe_clone(opcard) - table.insert(actice_card,card) + table.insert(actice_card, card) local p = _room:GetPlayerById(playerid) self._cacheEvent:Enqueue(function() - local isNeedDelHandCard =0 - p.hu_xi = huxi - local fz = {} - fz.card = card - fz.type = ftype - fz.active_card = actice_card - fz.from_seat = from_seat - fz.opcard =opcard - local remove_num = #opcard - if ftype == RB_FZTypeFLS.Chi then - p.fz_list[#p.fz_list+1] = fz + local isNeedDelHandCard = 0 + p.hu_xi = huxi + local fz = {} + fz.card = card + fz.type = ftype + fz.active_card = actice_card + fz.from_seat = from_seat + fz.opcard = opcard + local remove_num = #opcard + if ftype == RB_FZTypeFLS.Chi then + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZTypeFLS.Peng then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end - elseif ftype == RB_FZTypeFLS.Gang or ftype == RB_FZTypeFLS.SGang or ftype == RB_FZTypeFLS.Zhao or ftype == RB_FZTypeFLS.SZhao then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end - end - - p.tempOutcartList=outcard_list + + p.tempOutcartList = outcard_list p.hand_left_count = p.hand_left_count - remove_num - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p) - + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p) end) end @@ -499,18 +471,18 @@ function M:OnEventHu(evt_data) local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) - -- print(win_p.hand_left_count) - + -- -- print(win_p.hand_left_count) + self._cacheEvent:Enqueue(function() win_p.card_list = cards - table.sort( win_p.card_list, ViewUtil.HandCardSort) - DispatchEvent(self._dispatcher,RB_GameEvent.ZPHuCard, evt_data["seat"],evt_data["from_seat"],cards) + table.sort(win_p.card_list, ViewUtil.HandCardSort) + DispatchEvent(self._dispatcher, RB_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards) end) end function M:OneventResult1(evt_data) - printlog("结算=============>>>") - pt(evt_data) + printlog("结算=============>>>") + pt(evt_data) local over = evt_data.type --0:小结算 1:小大结算 2:大结算 self._room.playing = false @@ -522,17 +494,17 @@ function M:OneventResult1(evt_data) p.outcard_list = {} end self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult1, result); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult1, result); end) elseif 1 == over or 2 == over then DataManager.CurrenRoom.Over = true - ControllerManager.SetGameNetClient(nil,true) + ControllerManager.SetGameNetClient(nil, true) local total_result = evt_data.total_result local result = evt_data.result self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult2, result, total_result, over); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult2, result, total_result, over); end) end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/fulushou/EXMainView.lua b/lua_probject/extend_project/extend/zipai/fulushou/EXMainView.lua index dcb92b9c..79de16b5 100644 --- a/lua_probject/extend_project/extend/zipai/fulushou/EXMainView.lua +++ b/lua_probject/extend_project/extend/zipai/fulushou/EXMainView.lua @@ -22,8 +22,8 @@ local Fix_Msg_Chat = { --- Create a new ZZ_MainView function M.new() - setmetatable(M, {__index = ZPMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = ZPMainView }) + local self = setmetatable({}, { __index = M }) self.class = 'RunBeard_MainView' self._full = true self:init() @@ -37,19 +37,20 @@ function M:getCardItem(card_1, card_2) return card_1 .. '1_' .. card_2 end end + function M:InitView(url) local _room = self._room self.Fix_Msg_Chat = Fix_Msg_Chat ViewUtil.PlayMuisc('FuLuShou_ZP', 'extend/zipai/fulushou/sound/bgMain.mp3') UIPackage.AddPackage('extend/zipai/fulushou/ui/Extend_Poker_FuLuShou') ZPMainView.InitView(self, 'ui://Main_RunBeardMaJiang/Main_' .. _room.room_config.people_num, false, false, 1.2, 8) - - + + self:PlayerChangeLineState() SettingView.onEXMainCallback = handler(self, self.UpdateCardDisplay) SettingView.onUpdataCardSizeCallback = handler(self, self.UpdateCardSize) - + for i = 1, #_room.player_list do local p = _room.player_list[i] @@ -124,186 +125,172 @@ function M:setBtn() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end - function M:NewPlayerCardInfoView(view, index) if index == 1 then return PlayerSelfCardInfoView.new(view, self) end return PlayerCardInfoView.new(view, self) end + function M:closeTipOnTuoguan() if self._clearingView ~= nil then self._clearingView:Close() end self:__CloseTip() end + function M:EventInit() MainView.EventInit(self) local _room = self._room local _view = self._view local _player_info = self._player_info local _gamectr = self._gamectr - - - - _gamectr:AddEventListener(GameEvent.TuoGuanTipsEvt,function( ... ) - local arg = {...} - local isOpen=arg[1] - local self_Player=_player_info[self:GetPos( _room.self_player.seat)] - --local entrust_time=DataManager.CurrenRoom.entrust_time - --printlog("11111111111111",entrust_time) - if self_Player then - local btn_TG=self_Player._view:GetChild("Btn_tuoguan") - if btn_TG then - local tempTG=self_Player._view:GetController("tuoguan") - if tempTG then - if isOpen then - tempTG.selectedIndex=1 - else - tempTG.selectedIndex=0 - end - - end - - btn_TG.onClick:Set( - function() - local tuoguan_msg = MsgWindow.new(self._root_view, '确定托管吗?', MsgWindow.MsgMode.OkAndCancel) - tuoguan_msg.onOk:Add( - function() - self._gamectr:OnEvtOpenGameHuTuoGtips(true) - tuoguan_msg:Close() - tempTG.selectedIndex=0 - end - ) - tuoguan_msg:Show() - - end) - - - - - end - - end - - - end) - - - - _gamectr:AddEventListener(GameEvent.EventXiPai,function( ... ) - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] - - if self._player_card_info[1].HidePiao then - self._player_card_info[1]:HidePiao() - end - - self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - - end - - - if ( currentPlayer2 ) then - --self._popEvent = false - local xipaiCB2=function () - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end - - - end) - - - - _gamectr:AddEventListener(GameEvent.OnPiaoTips, function(...) - local arg = {...} + + _gamectr:AddEventListener(GameEvent.TuoGuanTipsEvt, function(...) + local arg = { ... } + local isOpen = arg[1] + local self_Player = _player_info[self:GetPos(_room.self_player.seat)] + --local entrust_time=DataManager.CurrenRoom.entrust_time + --printlog("11111111111111",entrust_time) + if self_Player then + local btn_TG = self_Player._view:GetChild("Btn_tuoguan") + if btn_TG then + local tempTG = self_Player._view:GetController("tuoguan") + if tempTG then + if isOpen then + tempTG.selectedIndex = 1 + else + tempTG.selectedIndex = 0 + end + end + + btn_TG.onClick:Set( + function() + local tuoguan_msg = MsgWindow.new(self._root_view, '确定托管吗?', MsgWindow.MsgMode.OkAndCancel) + tuoguan_msg.onOk:Add( + function() + self._gamectr:OnEvtOpenGameHuTuoGtips(true) + tuoguan_msg:Close() + tempTG.selectedIndex = 0 + end + ) + + tuoguan_msg:Show() + end) + end + end + end) + + + + + _gamectr:AddEventListener(GameEvent.EventXiPai, function(...) + local arg = { ... } + local currentPlayer1 = arg[1] + local currentPlayer2 = arg[2] + + if self._player_card_info[1].HidePiao then + self._player_card_info[1]:HidePiao() + end + + self._popEvent = false + if (currentPlayer1) then + local xipaiCB = function() + self._popEvent = true + end + self:PlayXiPai(xipaiCB) + end + + + if (currentPlayer2) then + --self._popEvent = false + local xipaiCB2 = function() + self._popEvent = true + end + self:PlayXiPai1(xipaiCB2) + end + end) + + + + _gamectr:AddEventListener(GameEvent.OnPiaoTips, function(...) + local arg = { ... } local piao = arg[1] local reload = arg[2] - local last_piao = arg[3] - local last_winer = arg[4] - - if piao >0 and piao <3 then piao=1 end - - - if reload==0 then - --self._popEvent = false - self._leftcard = 1 - self._leftcard = 1 - local rightpanel = self._view:GetChild('right_panel') - local tex_round = rightpanel:GetChild('tex_round') - if tex_round ~= nil then - tex_round.text = '第 ' .. _room.curren_round .. ' 局' - end - self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. '/' .. _room.room_config.round .. ' 局' + local last_piao = arg[3] + local last_winer = arg[4] - self._state.selectedIndex = 1 - self:closeTipOnTuoguan() - local list = _room.player_list - for i = 1, #list do - local p = list[i] - p.hu_xi = 0 - local _info = self._player_card_info[self:GetPos(p.seat)] - _info:SetPlayer(p) - local info = self._player_info[self:GetPos(p.seat)] - info:FillData(p) - info:MarkBank(p.seat == _room.banker_seat) - info:Ready(false) - info:UpdatePiao(-1) - info._view:GetController('huxi').selectedIndex = 1 - info._view:GetChild('huxi').text ="" --p.hu_xi - info._view:GetController('zhanji').selectedIndex = 0 + if piao > 0 and piao < 3 then piao = 1 end + + + if reload == 0 then + --self._popEvent = false + self._leftcard = 1 + self._leftcard = 1 + local rightpanel = self._view:GetChild('right_panel') + local tex_round = rightpanel:GetChild('tex_round') + if tex_round ~= nil then + tex_round.text = '第 ' .. _room.curren_round .. ' 局' + end + self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. '/' .. _room.room_config.round .. ' 局' + + self._state.selectedIndex = 1 + self:closeTipOnTuoguan() + local list = _room.player_list + for i = 1, #list do + local p = list[i] + p.hu_xi = 0 + local _info = self._player_card_info[self:GetPos(p.seat)] + _info:SetPlayer(p) + local info = self._player_info[self:GetPos(p.seat)] + info:FillData(p) + info:MarkBank(p.seat == _room.banker_seat) + info:Ready(false) + info:UpdatePiao(-1) + info._view:GetController('huxi').selectedIndex = 1 + info._view:GetChild('huxi').text = "" --p.hu_xi + info._view:GetController('zhanji').selectedIndex = 0 + + if _room.hpOnOff == 1 or _room:checkHpNonnegative() then + if p.total_hp == nil then + p.total_hp = 0 + end + info._view:GetController('zhanji').selectedIndex = 1 + info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) + end + end + end + --local card_info = self._player_card_info[1] + --card_info:UpdateIsOnClick(false) + --card_info:InitHandCard(true) + printlog("飘分提示==>>>") + if last_winer == 1 then + self._player_card_info[1]:ShowSpecialPiao(piao, last_piao) + else + self._player_card_info[1]:ShowPiao(piao) + end + end) - if _room.hpOnOff == 1 or _room:checkHpNonnegative() then - if p.total_hp == nil then - p.total_hp = 0 - end - info._view:GetController('zhanji').selectedIndex = 1 - info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) - end - end - - end - --local card_info = self._player_card_info[1] - --card_info:UpdateIsOnClick(false) - --card_info:InitHandCard(true) - printlog("飘分提示==>>>") - if last_winer==1 then - self._player_card_info[1]:ShowSpecialPiao(piao,last_piao) - else - self._player_card_info[1]:ShowPiao(piao) - end - - end) - _gamectr:AddEventListener(GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] head_info:UpdatePiao(piao) end) - + _gamectr:AddEventListener( GameEvent.SendCards, function(...) @@ -350,15 +337,15 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.GetCard, function(...) - self._popEvent = false - local arg = {...} + self._popEvent = false + local arg = { ... } local seat = arg[1] local card = arg[2] local _leftcard = arg[3] self._left_time = 15 self._tex_LeftCard.text = '剩余 ' .. _leftcard .. ' 张牌' local info = self._player_card_info[self:GetPos(seat)] - + info:UpdateOutCardList(card, true, true, self:GetPos(seat)) if card ~= 0 then local p = _room:GetPlayerBySeat(seat) @@ -367,10 +354,10 @@ function M:EventInit() coroutine.start( function() coroutine.wait(0.2) - if seat == self._room.self_player.seat then - info:InitHandCard(false) - info:ChuPaiTiShi() - end + if seat == self._room.self_player.seat then + info:InitHandCard(false) + info:ChuPaiTiShi() + end self._popEvent = true info:ClearOutCard() end @@ -382,7 +369,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.ShowremainCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local _leftcard = arg[2] self._tex_LeftCard.text = '剩余 ' .. _leftcard .. ' 张牌' @@ -392,7 +379,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.AddCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] self._popEvent = false @@ -413,7 +400,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.EventTurn, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local list = _room.player_list local readyNum = 0 @@ -443,10 +430,10 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.OutCard, function(...) - self._popEvent = false + self._popEvent = false self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -455,11 +442,10 @@ function M:EventInit() if seat == self._room.self_player.seat then _room.curren_outcard_seat = -1 --info:DeleteHandCard(card) - info:InitHandCard(false) + info:InitHandCard(false) info:UpdateIsOnClick(true) --info:SendChangeCard() info:ChuPaiTiShi() - end local list = _room.player_list for i = 1, #list do @@ -476,24 +462,22 @@ function M:EventInit() card_info:UpdateFzList(p.fz_list, false, p.seat) end end - - ------ - --if(not p.outcard_list) then p.outcard_list = {} end - --p.outcard_list[#p.outcard_list+1] = card - - coroutine.start( + + ------ + --if(not p.outcard_list) then p.outcard_list = {} end + --p.outcard_list[#p.outcard_list+1] = card + + coroutine.start( function() coroutine.wait(0.5) local info = self._player_card_info[self:GetPos(seat)] - info:PlayingOutCardAnima(p.DiceCard) - p.DiceCard = 0 - info:UpdateQiPai(p.outcard_list, true, seat) - - self._popEvent = true + info:PlayingOutCardAnima(p.DiceCard) + p.DiceCard = 0 + info:UpdateQiPai(p.outcard_list, true, seat) + + self._popEvent = true end ) - - end ) @@ -503,11 +487,11 @@ function M:EventInit() self:__CloseTip() self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] local p = _room:GetPlayerBySeat(seat) - --p.DiceCard=card + --p.DiceCard=card local info = self._player_card_info[self:GetPos(seat)] info:PlayingOutCardAnima(p.DiceCard) p.DiceCard = 0 @@ -518,7 +502,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] --local _uid = arg[2] self:__FangziTip(_tip) @@ -533,7 +517,7 @@ function M:EventInit() self._left_time = 0 self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local w = arg[1] local l = arg[2] local cards = arg[3] @@ -569,7 +553,7 @@ function M:EventInit() function(...) self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -648,7 +632,7 @@ function M:EventInit() GameEvent.ZPResult2, function(...) self._left_time = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -682,19 +666,19 @@ function M:ChangeCards(list) end function M:__FangziTip(tip) - printlog("进入放子提示流程===>>>") - --pt(tip) - self._popEvent=false + printlog("进入放子提示流程===>>>") + --pt(tip) + self._popEvent = false local _gamectr = self._gamectr local _chipeng_tip = UIPackage.CreateObject('Main_RunBeardMaJiang', 'Gcm_action_tips') - --printlog("Gcm_action_tips===>>>",_chipeng_tip) + --printlog("Gcm_action_tips===>>>",_chipeng_tip) self._chipeng_tip = _chipeng_tip local p = self._room.self_player local _lit_fanzi = _chipeng_tip:GetChild('lit_fanzi') _lit_fanzi:RemoveChildrenToPool() local _tlist = table.keys(tip.tip_map_type) - pt(_tlist) + pt(_tlist) local tip_hu = false local count = #_tlist for k = 1, #_tlist do @@ -705,17 +689,17 @@ function M:__FangziTip(tip) end for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] - --printlog("td==",td) + --printlog("td==",td) local url = 'ui://Main_RunBeardMaJiang/Btn_fztip' local btn_t = _lit_fanzi:AddItemFromPool(url) - printlog("td.type==",td.type) - --printlog("btn_t==",btn_t) - --if td.type==6 then - btn_t:GetChild("hupai").icon="ui://Main_RunBeardMaJiang/201_1_" .. td.card - btn_t:GetController("hupai").selectedIndex=1 - --end + printlog("td.type==", td.type) + --printlog("btn_t==",btn_t) + --if td.type==6 then + btn_t:GetChild("hupai").icon = "ui://Main_RunBeardMaJiang/201_1_" .. td.card + btn_t:GetController("hupai").selectedIndex = 1 + --end btn_t.icon = 'ui://Main_RunBeardMaJiang/newop_' .. td.type - btn_t.data = {tip, td, tip_hu} + btn_t.data = { tip, td, tip_hu } btn_t.onClick:Set(self.__TipAction, self) end if p.hand_left_count ~= 0 then @@ -747,8 +731,9 @@ function M:__FangziTip(tip) _chipeng_tip:Center() _chipeng_tip.x = _chipeng_tip.x + 200 _chipeng_tip.y = _chipeng_tip.y - 130 - self._popEvent=true + self._popEvent = true end + function M:__TipAction(context) local data = context.sender.data local _gamectr = self._gamectr @@ -756,8 +741,8 @@ function M:__TipAction(context) local td = data[2] local tip_hu = data[3] local list = tip.tip_map_type[td.weight] - --printlog("__TipAction==>>>",td.type) - --pt(list) + --printlog("__TipAction==>>>",td.type) + --pt(list) if #list > 1 then self:_ChiView( list, @@ -782,12 +767,11 @@ function M:__TipAction(context) info:UpdateIsOnClick(false) end end - ,td.type + , td.type ) --self._chipeng_tip.visible = false return - - end + end if tip_hu and td.type ~= 7 then local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel) guo_msg.onOk:Add( @@ -816,7 +800,7 @@ function M:__TipAction(context) end end -function M:_ChiView(tip_list, tip_hu, callback,typeValue) +function M:_ChiView(tip_list, tip_hu, callback, typeValue) local _pop_tip_choice = UIPackage.CreateObject('Main_RunBeardMaJiang', 'Pop_tip_choice') local list_choose = _pop_tip_choice:GetChild('Lst_choose') _pop_tip_choice:GetChild('dibtn').onClick:Add( @@ -824,71 +808,69 @@ function M:_ChiView(tip_list, tip_hu, callback,typeValue) _pop_tip_choice:Dispose() end ) - list_choose:RemoveChildrenToPool() - if typeValue and (typeValue==4 or typeValue==6) then - if typeValue==4 then - _pop_tip_choice:GetChild('n65').text="杠 牌" - else - _pop_tip_choice:GetChild('n65').text="招 牌" - end - - for i = 1, #tip_list do - --if tip_list[i].weight == 4 then - local item_choose = list_choose:AddItemFromPool() - item_choose:GetChild('card' .. 2).icon = - UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].card)) - - item_choose.onClick:Add( - function() - for k = 1, list_choose.numChildren do - list_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0 - end - item_choose:GetController('zhong').selectedIndex = 1 - if tip_list[i].bi_list == nil then - callback(tip_list[i].id) - else - self.bilist = {} - self._chiid = tip_list[i].id - self:CheckRatioCard(tip_list[i].bi_list, 1, tip_list[i].card) - end - end - ) - --end - end - else - - for i = 1, #tip_list do - if tip_list[i].weight ~= 4 then - local item_choose = list_choose:AddItemFromPool() - item_choose:GetChild('card' .. 2).icon = - UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].OpCard[1])) - item_choose:GetChild('card' .. 3).icon = - UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].OpCard[2])) - item_choose:GetChild('card' .. 1).icon = - UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].card)) + list_choose:RemoveChildrenToPool() + if typeValue and (typeValue == 4 or typeValue == 6) then + if typeValue == 4 then + _pop_tip_choice:GetChild('n65').text = "杠 牌" + else + _pop_tip_choice:GetChild('n65').text = "招 牌" + end + + for i = 1, #tip_list do + --if tip_list[i].weight == 4 then + local item_choose = list_choose:AddItemFromPool() + item_choose:GetChild('card' .. 2).icon = + UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].card)) + + item_choose.onClick:Add( + function() + for k = 1, list_choose.numChildren do + list_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0 + end + item_choose:GetController('zhong').selectedIndex = 1 + if tip_list[i].bi_list == nil then + callback(tip_list[i].id) + else + self.bilist = {} + self._chiid = tip_list[i].id + self:CheckRatioCard(tip_list[i].bi_list, 1, tip_list[i].card) + end + end + ) + --end + end + else + for i = 1, #tip_list do + if tip_list[i].weight ~= 4 then + local item_choose = list_choose:AddItemFromPool() + item_choose:GetChild('card' .. 2).icon = + UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].OpCard[1])) + item_choose:GetChild('card' .. 3).icon = + UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].OpCard[2])) + item_choose:GetChild('card' .. 1).icon = + UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].card)) + + item_choose.onClick:Add( + function() + for k = 1, list_choose.numChildren do + list_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0 + end + item_choose:GetController('zhong').selectedIndex = 1 + if tip_list[i].bi_list == nil then + callback(tip_list[i].id) + else + self.bilist = {} + self._chiid = tip_list[i].id + self:CheckRatioCard(tip_list[i].bi_list, 1, tip_list[i].card) + end + end + ) + end + end + end + - item_choose.onClick:Add( - function() - for k = 1, list_choose.numChildren do - list_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0 - end - item_choose:GetController('zhong').selectedIndex = 1 - if tip_list[i].bi_list == nil then - callback(tip_list[i].id) - else - self.bilist = {} - self._chiid = tip_list[i].id - self:CheckRatioCard(tip_list[i].bi_list, 1, tip_list[i].card) - end - end - ) - end - end - - end - - list_choose:ResizeToFit(#tip_list) _pop_tip_choice:GetChild('di1').width = list_choose.width + 110 _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, -100) @@ -977,13 +959,13 @@ function M:deepcopy(object) end function M:OnFangziAction(...) - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] --local num = arg[3] --if fz.type == RB_FZTypeFLS.Peng or fz.type == RB_FZTypeFLS.Chi or fz.type == RB_FZTypeFLS.Bi then - self:__CloseTip() + self:__CloseTip() --end if (player == self._room.self_player) then local info = _player_card_info[self:GetPos(player.seat)] @@ -1002,22 +984,21 @@ function M:OnFangziAction(...) for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end - elseif fz == RB_FZTypeFLS.Gang or fz == RB_FZTypeFLS.SGang or fz == RB_FZTypeFLS.Zhao or fz == RB_FZTypeFLS.SZhao then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end end - - - info:InitHandCard(false) + + + info:InitHandCard(false) end if fz.type ~= RB_FZTypeFLS.Kan and fz.type ~= RB_FZTypeFLS.Bi then local info = _player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai local effect = UIPackage.CreateObject('Extend_Poker_FuLuShou', 'FzEffect') - if fz.type == RB_FZTypeFLS.Peng then + if fz.type == RB_FZTypeFLS.Peng then self:PlaySound(player.self_user.sex, 'F_Peng') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', 'peng') elseif fz.type == RB_FZTypeFLS.Chi then @@ -1041,29 +1022,29 @@ function M:OnFangziAction(...) end ) end - - - if player.tempOutcartList then - for i=1,#player.tempOutcartList do - local infoP= DataManager.CurrenRoom:GetPlayerById(player.tempOutcartList[i].playerid) - if infoP then - infoP.outcard_list=player.tempOutcartList[i].outcard_list - local infoC = _player_card_info[self:GetPos(infoP.seat)] - if infoC then - infoC:UpdateQiPai(infoP.outcard_list) - end - end - end - end - - + + + if player.tempOutcartList then + for i = 1, #player.tempOutcartList do + local infoP = DataManager.CurrenRoom:GetPlayerById(player.tempOutcartList[i].playerid) + if infoP then + infoP.outcard_list = player.tempOutcartList[i].outcard_list + local infoC = _player_card_info[self:GetPos(infoP.seat)] + if infoC then + infoC:UpdateQiPai(infoP.outcard_list) + end + end + end + end + + if (player == self._room.self_player) then coroutine.start( function() coroutine.wait(0.5) local info = _player_card_info[self:GetPos(player.seat)] info:ShowHuTip() - info:ChuPaiTiShi() + info:ChuPaiTiShi() end ) end @@ -1077,15 +1058,15 @@ function M:OnFangziAction(...) for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] - --print(p.hu_xi) + ---- print(p.hu_xi) info._view:GetChild('huxi').text = p.hu_xi end - - if player == self._room.self_player then - local info = _player_card_info[self:GetPos(player.seat)] - info:SetNotPutCard() - end - + + if player == self._room.self_player then + local info = _player_card_info[self:GetPos(player.seat)] + info:SetNotPutCard() + end + self._popEvent = true coroutine.start( function() @@ -1120,13 +1101,13 @@ function M:ReloadRoom() else self._player_info[self:GetPos(p.seat)]:Ready(false) end - - --if p.piao then - -- self._player_info[self:GetPos(p.seat)]:UpdatePiao(-1) - --else - self._player_info[self:GetPos(p.seat)]:UpdatePiao(p.piao) - --end - + + --if p.piao then + -- self._player_info[self:GetPos(p.seat)]:UpdatePiao(-1) + --else + self._player_info[self:GetPos(p.seat)]:UpdatePiao(p.piao) + --end + if self._state.selectedIndex == 1 then local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('huxi').selectedIndex = 1 @@ -1179,8 +1160,8 @@ function M:ReloadRoom() else card_info:InitHandCard(false) end--]] - - card_info:InitHandCard(false) + + card_info:InitHandCard(false) card_info:ShowHuTip() for i = 1, #p.fz_list do if p.fz_list[i].type == RB_FZTypeFLS.Kan then @@ -1190,7 +1171,7 @@ function M:ReloadRoom() end end - printlog("jefe abcs",room.left_count); + printlog("jefe abcs", room.left_count); self._tex_LeftCard.text = '剩余 ' .. room.left_count .. ' 张牌' local rightpanel = self._view:GetChild('right_panel') @@ -1210,7 +1191,7 @@ end function M:PlaySound(sex, path) local sex_path = ViewUtil.Sex_Chat[1] -- 1 男 2 女 local sound_path = string.format('extend/zipai/fulushou/sound/%s/%s.mp3', sex_path, path) - printlog(sound_path) + printlog(sound_path) ViewUtil.PlaySound('FuLuShou_ZP', sound_path) end diff --git a/lua_probject/extend_project/extend/zipai/fulushou/EXPlayBackView.lua b/lua_probject/extend_project/extend/zipai/fulushou/EXPlayBackView.lua index e4f80a20..7a564f41 100644 --- a/lua_probject/extend_project/extend/zipai/fulushou/EXPlayBackView.lua +++ b/lua_probject/extend_project/extend/zipai/fulushou/EXPlayBackView.lua @@ -22,8 +22,8 @@ end --- Create a new function M.new() - setmetatable(M, {__index = PlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'PlayBackView' self:init() @@ -156,7 +156,7 @@ function M:ShowStep(index) p.fz_list = step.player_card_data[i].fz_list p.hu_xi = step.player_card_data[i].hu_xi p.hand_left_count = #p.card_list - + if index == 1 then info:Clear() if p.total_hp then @@ -174,21 +174,21 @@ function M:ShowStep(index) local infoHand = self._player_info[self:GetPos(p.seat)] infoHand._view:GetChild('huxi').text = p.hu_xi end - + if step.cmd == Record_Event.Evt_Action then if p.fz_list ~= nil and #p.fz_list > 0 then info:UpdateFzList1(p.fz_list) end end - - - - + + + + if step.cmd == Record_Event.Evt_GetCard then if step.DiceCard ~= nil and step.DiceCard ~= 0 then if p.seat == step.seat then info:UpdateOutCardList(step.DiceCard) - self.lastCard=step.DiceCard + self.lastCard = step.DiceCard coroutine.start( function() coroutine.wait(0.5) @@ -199,11 +199,11 @@ function M:ShowStep(index) end end - if step.cmd == Record_Event.Evt_OutCard then + if step.cmd == Record_Event.Evt_OutCard then if step.DiceCard ~= nil and step.DiceCard ~= 0 then if p.seat == step.seat then info:UpdateOutCardList(step.DiceCard) - self.lastCard=step.DiceCard + self.lastCard = step.DiceCard coroutine.start( function() coroutine.wait(1) @@ -213,33 +213,30 @@ function M:ShowStep(index) end end end - - - + + + if p.outcard_list ~= nil then info:UpdateQiPai(p.outcard_list) end - - if p.seat ~= self._room.self_player.seat then + + if p.seat ~= self._room.self_player.seat then info:InitHandCard(p.card_list) else self._room.self_player.handcard_list = p.card_list info:InitHandCard(false) end - - if step.cmd== Record_Event.Evt_Win then - if p.seat == step.win and self.lastCard then - info:UpdateOutCardList(self.lastCard) - end - end - - - --info:InitHandCard(p.card_list) - - - + + if step.cmd == Record_Event.Evt_Win then + if p.seat == step.win and self.lastCard then + info:UpdateOutCardList(self.lastCard) + end + end + + + --info:InitHandCard(p.card_list) end - -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) + -- -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) if step.cmd == Record_Event.Evt_result then local _room = DataManager.CurrenRoom local result = step.result @@ -327,8 +324,8 @@ function M:GenerateAllStepData(data) end function M:CmdOutCard(cmd, index) - printlog("出牌==》》》》") - pt(cmd) + printlog("出牌==》》》》") + pt(cmd) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.current_out_seat = cmd.seat @@ -336,24 +333,24 @@ function M:CmdOutCard(cmd, index) list_remove(u.card_list, cmd.data.card) data.seat = cmd.seat data.DiceCard = cmd.data.card - - data.out_card_list = cmd.data.card + + data.out_card_list = cmd.data.card u.outcard_list[#u.outcard_list + 1] = cmd.data.card end function M:CmdGetCard(cmd, index) - print("抓牌==》》》") - pt(cmd) + -- print("抓牌==》》》") + pt(cmd) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.left_card = cmd.data.left_count local u = data.player_card_data[cmd.seat] data.seat = cmd.seat data.DiceCard = cmd.data.card - - u.card_list[#u.card_list + 1] = cmd.data.card - + + u.card_list[#u.card_list + 1] = cmd.data.card end + function M:CmdThrowCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -363,6 +360,7 @@ function M:CmdThrowCard(cmd, index) data.out_card_list = cmd.data.card u.outcard_list[#u.outcard_list + 1] = cmd.data.card end + function M:CmdAddCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -385,8 +383,8 @@ function M:CmdChangePaiXing(cmd, index) end function M:CmdAction(cmd, index) - printlog("吃杠彭行为=====》》》》》") - pt(cmd) + printlog("吃杠彭行为=====》》》》》") + pt(cmd) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.seat = cmd.seat @@ -422,7 +420,7 @@ function M:CmdAction(cmd, index) for i = 1, #p.fz_list do if p.fz_list[i].card == card then p.fz_list[i].type = RB_FZTypeFLS.Gang - -- isAddTi = true + -- isAddTi = true end end if num > 0 then @@ -438,7 +436,7 @@ function M:CmdAction(cmd, index) end function M:CmdWin(cmd, index) - pt("赢牌===>>>",cmd) + pt("赢牌===>>>", cmd) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.win = cmd.seat diff --git a/lua_probject/extend_project/extend/zipai/fulushou/PlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/zipai/fulushou/PlayerSelfCardInfoView.lua index cdf91b50..6276b63e 100644 --- a/lua_probject/extend_project/extend/zipai/fulushou/PlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/zipai/fulushou/PlayerSelfCardInfoView.lua @@ -1,346 +1,318 @@ local PlayerSelfCardInfoView = import(".main.ZPPlayerSelfCardInfoView") local CardCheck = import(".main.CardCheck") -local SanPaiInfoView=import(".SanPaiInfoView") +local SanPaiInfoView = import(".SanPaiInfoView") local M = {} --- -function M.new(view,mainView) - setmetatable(M, {__index = PlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(M, { __index = PlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView self._full = true self:init() - self.onclickNum=0 + self.onclickNum = 0 return self end - function M:onTouchBegin(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end - --printlog("点击卡牌=============================>>>") - self.onclickNum=self.onclickNum+1 + --printlog("点击卡牌=============================>>>") + self.onclickNum = self.onclickNum + 1 local button = context.sender local card = button.data - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self:ShowHuTip(card.card_item) end - card.startPos=Vector2.New(card.btn_card.x,card.btn_card.y) - local tempOrder=card.btn_card.sortingOrder or 1 - card.order=tonumber(tempOrder) - - card.btn_card:GetController('cardnum').selectedIndex=0 - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/203_",card.card_item) - - - card.btn_card.sortingOrder = 100 - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - card.btn_card.xy = Vector2.New(card.btn_card.x+20 ,card.btn_card.y-50) - card.touch_pos = xy - button.xy + card.startPos = Vector2.New(card.btn_card.x, card.btn_card.y) + local tempOrder = card.btn_card.sortingOrder or 1 + card.order = tonumber(tempOrder) + card.btn_card:GetController('cardnum').selectedIndex = 0 + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/203_", card.card_item) + + + card.btn_card.sortingOrder = 100 + local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50) + card.touch_pos = xy - button.xy end function M:__OnDragEnd(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end - --printlog("点击结束卡牌============================>>>") + --printlog("点击结束卡牌============================>>>") local button = context.sender - + local card = button.data - + local _room = DataManager.CurrenRoom if (button.y < -480 and _room.curren_outcard_seat == _room.self_player.seat) then - local OutCardCallBackFunc=function () - button.touchable = false - self.outcard_button = card - self:UpdateIsOnClick(false) - self._mainView:OutCard(card.card_item) - end - - local tingpaiList=DataManager.CurrenRoom.self_player.tingPaiList - local isHasTing=CheckDictionaryFromContent(card.card_item,DataManager.CurrenRoom.self_player.tingPaiList) - --printlog("是否包含有====》》》》",isHasTing) - --pt(tingpaiList) - if isHasTing==nil then isHasTing=false end - - if isHasTing==false and tingpaiList and #tingpaiList>0 then - local spCallBackFunc=function (isOP) - if isOP then - OutCardCallBackFunc() - else - local isChangeCard = false - self.outcard_button = nil - card.btn_card:GetController('cardnum').selectedIndex=card.sameNum-1 - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/201_",card.card_item) - self._area_handcard_list:AddChild(button) - if card.btn_card.sortingOrder then - card.btn_card.sortingOrder = card.order or 1 - end - - if #self.card_list == 1 then - isChangeCard = false - self:UpdateHandCardsPos() - return - end - card.btn_card.xy=card.startPos - end - end - local SPView=SanPaiInfoView.new(spCallBackFunc) + local OutCardCallBackFunc = function() + button.touchable = false + self.outcard_button = card + self:UpdateIsOnClick(false) + self._mainView:OutCard(card.card_item) + end - - else - OutCardCallBackFunc() - end - - - - + local tingpaiList = DataManager.CurrenRoom.self_player.tingPaiList + local isHasTing = CheckDictionaryFromContent(card.card_item, DataManager.CurrenRoom.self_player.tingPaiList) + --printlog("是否包含有====》》》》",isHasTing) + --pt(tingpaiList) + if isHasTing == nil then isHasTing = false end + + if isHasTing == false and tingpaiList and #tingpaiList > 0 then + local spCallBackFunc = function(isOP) + if isOP then + OutCardCallBackFunc() + else + local isChangeCard = false + self.outcard_button = nil + card.btn_card:GetController('cardnum').selectedIndex = card.sameNum - 1 + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/201_", + card.card_item) + self._area_handcard_list:AddChild(button) + if card.btn_card.sortingOrder then + card.btn_card.sortingOrder = card.order or 1 + end + + if #self.card_list == 1 then + isChangeCard = false + self:UpdateHandCardsPos() + return + end + card.btn_card.xy = card.startPos + end + end + local SPView = SanPaiInfoView.new(spCallBackFunc) + else + OutCardCallBackFunc() + end else local isChangeCard = false self.outcard_button = nil - card.btn_card:GetController('cardnum').selectedIndex=card.sameNum-1 - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/201_",card.card_item) + card.btn_card:GetController('cardnum').selectedIndex = card.sameNum - 1 + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/201_", card.card_item) self._area_handcard_list:AddChild(button) - - if card.btn_card.sortingOrder then - card.btn_card.sortingOrder = card.order or 1 - end - + + if card.btn_card.sortingOrder then + card.btn_card.sortingOrder = card.order or 1 + end + if #self.card_list == 1 then isChangeCard = false self:UpdateHandCardsPos() return end - card.btn_card.xy=card.startPos + card.btn_card.xy = card.startPos end end - - - - function M:__OnClickHandCard(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end - - local button = context.sender - - local card = button.data - - local _room = DataManager.CurrenRoom - - if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then - local OutCardCallBackFunc=function () - button.touchable = false - self.outcard_button = card - self:UpdateIsOnClick(false) - self._mainView:OutCard(card.card_item) - end - - local tingpaiList=DataManager.CurrenRoom.self_player.tingPaiList - local isHasTing=CheckDictionaryFromContent(card.card_item,DataManager.CurrenRoom.self_player.tingPaiList) - --printlog("是否包含有====》》》》",isHasTing) - --pt(tingpaiList) - if isHasTing==nil then isHasTing=false end - - if isHasTing==false and tingpaiList and #tingpaiList>0 then - local spCallBackFunc=function (isOP) - if isOP then - OutCardCallBackFunc() - else - local isChangeCard = false - self.outcard_button = nil - card.btn_card:GetController('cardnum').selectedIndex=card.sameNum-1 - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/201_",card.card_item) - self._area_handcard_list:AddChild(button) - if card.btn_card.sortingOrder then - card.btn_card.sortingOrder = card.order or 1 - end - - if #self.card_list == 1 then - isChangeCard = false - self:UpdateHandCardsPos() - return - end - card.btn_card.xy=card.startPos - end - end - local SPView=SanPaiInfoView.new(spCallBackFunc) - - else - OutCardCallBackFunc() - end - - - + local button = context.sender + + local card = button.data + + local _room = DataManager.CurrenRoom + + if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then + local OutCardCallBackFunc = function() + button.touchable = false + self.outcard_button = card + self:UpdateIsOnClick(false) + self._mainView:OutCard(card.card_item) + end + + local tingpaiList = DataManager.CurrenRoom.self_player.tingPaiList + local isHasTing = CheckDictionaryFromContent(card.card_item, DataManager.CurrenRoom.self_player.tingPaiList) + --printlog("是否包含有====》》》》",isHasTing) + --pt(tingpaiList) + if isHasTing == nil then isHasTing = false end + + if isHasTing == false and tingpaiList and #tingpaiList > 0 then + local spCallBackFunc = function(isOP) + if isOP then + OutCardCallBackFunc() + else + local isChangeCard = false + self.outcard_button = nil + card.btn_card:GetController('cardnum').selectedIndex = card.sameNum - 1 + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/201_", + card.card_item) + self._area_handcard_list:AddChild(button) + if card.btn_card.sortingOrder then + card.btn_card.sortingOrder = card.order or 1 + end + + if #self.card_list == 1 then + isChangeCard = false + self:UpdateHandCardsPos() + return + end + card.btn_card.xy = card.startPos + end + end + local SPView = SanPaiInfoView.new(spCallBackFunc) + else + OutCardCallBackFunc() + end end - - end - - - -function M:UpdateOutCardList(outcard,isShow,isMopai,seat) - self:HidePiao() - if(isShow == nil) then - isShow = false +function M:UpdateOutCardList(outcard, isShow, isMopai, seat) + self:HidePiao() + if (isShow == nil) then + isShow = false end - if(isMopai == nil) then - isMopai = false + if (isMopai == nil) then + isMopai = false end - self._area_outcard_list:RemoveChildren(0,-1,true) - local outcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Gcm_OutCard") - - if outcard==0 then - outcards:GetChild("icon").icon ="ui://Main_RunBeardMaJiang/202_1_300" + self._area_outcard_list:RemoveChildren(0, -1, true) + local outcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Gcm_OutCard") + + if outcard == 0 then + outcards:GetChild("icon").icon = "ui://Main_RunBeardMaJiang/202_1_300" else - outcards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeardMaJiang/203_",outcard) + outcards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/203_", outcard) end - outcards.x,outcards.y = 0,0 - local show_di_bg = outcards:GetChild("show_di_bg") - -- show_di_bg.visible = true - if(isShow)then - if outcard == 0 then - show_di_bg.visible = false - end - if(seat ~= nil and outcards~=nil)then - if(isMopai)then - if outcard ~= 0 then - outcards:GetTransition("mopai"..seat):Play(function( ) - -- show_di_bg.visible = true - - end) - end + outcards.x, outcards.y = 0, 0 + local show_di_bg = outcards:GetChild("show_di_bg") + -- show_di_bg.visible = true + if (isShow) then + if outcard == 0 then + show_di_bg.visible = false + end + if (seat ~= nil and outcards ~= nil) then + if (isMopai) then + if outcard ~= 0 then + outcards:GetTransition("mopai" .. seat):Play(function() + -- show_di_bg.visible = true + end) + end else - show_di_bg.visible = false - outcards:GetTransition("cpai"..seat):Play() + show_di_bg.visible = false + outcards:GetTransition("cpai" .. seat):Play() end - else - --show_di_bg.visible = true - end + else + --show_di_bg.visible = true + end else - show_di_bg.visible = false + show_di_bg.visible = false end self._area_outcard_list:AddChild(outcards) end --弃牌 -function M:UpdateQiPai( qi_list,isplay) - self._area_qipai_list:RemoveChildren(0,-1,true) - for i=1,#qi_list do - local qicards =UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Qipai") - qicards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeardMaJiang/202_",qi_list[i]) - if(isplay)then - if(i == #qi_list) then - qicards:GetTransition("t1"):Play() +function M:UpdateQiPai(qi_list, isplay) + self._area_qipai_list:RemoveChildren(0, -1, true) + for i = 1, #qi_list do + local qicards = UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Qipai") + qicards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_", qi_list[i]) + if (isplay) then + if (i == #qi_list) then + qicards:GetTransition("t1"):Play() end - end - self._area_qipai_list:AddChild(qicards) - end + end + self._area_qipai_list:AddChild(qicards) + end end --摸牌动画 -function M:PlayingOutCardAnima( card) +function M:PlayingOutCardAnima(card) coroutine.start(function() - coroutine.wait(0.1) + coroutine.wait(0.1) self:ClearOutCard() end) end -function M:UpdateFzList( fz_list ,ispaly) - self._area_fz_list:RemoveChildren(0,-1,true) - for i = 1,#fz_list do - local fzitem=nil +function M:UpdateFzList(fz_list, ispaly) + self._area_fz_list:RemoveChildren(0, -1, true) + for i = 1, #fz_list do + local fzitem = nil if fz_list[i].type ~= RB_FZTypeFLS.Kan then - fzitem =UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/ComponentNew") - if(ispaly == false)then - fzitem:RemoveChildren(0,-1,true) + fzitem = UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/ComponentNew") + if (ispaly == false) then + fzitem:RemoveChildren(0, -1, true) end end - if fz_list[i].type == RB_FZTypeFLS.Chi then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_3") + if fz_list[i].type == RB_FZTypeFLS.Chi then + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_3") --fzcards:GetChild("card_"..1).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].active_card) fzcards:GetController("c2").selectedIndex = 1 - -- fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].opcard[1]) + -- fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].opcard[1]) --fzcards:GetChild("card_"..3).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].opcard[2]) - for j=1,#fz_list[i].active_card do - fzcards:GetChild("card_"..j).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].active_card[j]) - end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + for j = 1, #fz_list[i].active_card do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_", + fz_list[i].active_card[j]) + end + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZTypeFLS.Peng then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_3") - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].active_card[j]) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_3") + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_", + fz_list[i].active_card[j]) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - - elseif fz_list[i].type == RB_FZTypeFLS.Gang or fz_list[i].type == RB_FZTypeFLS.Zhao then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_4") - for j=1,4 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].active_card[j]) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) + elseif fz_list[i].type == RB_FZTypeFLS.Gang or fz_list[i].type == RB_FZTypeFLS.Zhao then + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_4") + for j = 1, 4 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_", + fz_list[i].active_card[j]) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) + elseif fz_list[i].type == RB_FZTypeFLS.SGang or fz_list[i].type == RB_FZTypeFLS.SZhao then + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_4") - elseif fz_list[i].type == RB_FZTypeFLS.SGang or fz_list[i].type == RB_FZTypeFLS.SZhao then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeardMaJiang/Fz_0_4") - - for j=1,4 do - if j == 4 then - fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].active_card[j]) - else - fzcards:GetChild('card_' .. j).icon = 'ui://Main_RunBeardMaJiang/202_1_300' - end - - end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + for j = 1, 4 do + if j == 4 then + fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', + fz_list[i].active_card[j]) + else + fzcards:GetChild('card_' .. j).icon = 'ui://Main_RunBeardMaJiang/202_1_300' + end + end + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) end end end - -function M:playAnim( fzitem,fzcards, size,i,ispaly ) - if(ispaly == nil)then - ispaly =false - end - if(ispaly and i == size)then - local faArray= fzitem:GetChild("chiwei") - if(faArray~=nil)then - faArray:AddChild(fzcards) - else - fzitem:AddChild(fzcards) - end - else - fzitem:AddChild(fzcards) - end - self._area_fz_list:AddChild(fzitem) +function M:playAnim(fzitem, fzcards, size, i, ispaly) + if (ispaly == nil) then + ispaly = false + end + if (ispaly and i == size) then + local faArray = fzitem:GetChild("chiwei") + if (faArray ~= nil) then + faArray:AddChild(fzcards) + else + fzitem:AddChild(fzcards) + end + else + fzitem:AddChild(fzcards) + end + self._area_fz_list:AddChild(fzitem) end - - --出牌提示动画 - function M:ChuPaiTiShi() - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then +--出牌提示动画 +function M:ChuPaiTiShi() + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end --[[local chu_player = DataManager.CurrenRoom.self_player @@ -364,19 +336,19 @@ end end end if #tingList > 0 and isKan == false then - + mark_ting[#mark_ting+1] = card end table.insert(player.handcard_list, card) table.sort( player.handcard_list, ViewUtil.HandCardSort) end--]] - -- print("ChuPaiTiShi",#mark_ting,vardump(player)) - - - ---------------- - - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then - self._view :GetController("chupai").selectedIndex =1 + -- -- print("ChuPaiTiShi",#mark_ting,vardump(player)) + + + ---------------- + + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + self._view:GetController("chupai").selectedIndex = 1 --[[if #mark_ting>0 then for i=1,#mark_ting do for k=1,#self.card_list do @@ -387,37 +359,30 @@ end end end end--]] - - ---------------------- - if DataManager.CurrenRoom.self_player.tingPaiList and #DataManager.CurrenRoom.self_player.tingPaiList>0 then - for k=1,#self.card_list do - local card_view= self.card_list[k] - local isTing,curIndex=CheckDictionaryFromContent(card_view.card_item,DataManager.CurrenRoom.self_player.tingPaiList) + + ---------------------- + if DataManager.CurrenRoom.self_player.tingPaiList and #DataManager.CurrenRoom.self_player.tingPaiList > 0 then + for k = 1, #self.card_list do + local card_view = self.card_list[k] + local isTing, curIndex = CheckDictionaryFromContent(card_view.card_item, + DataManager.CurrenRoom.self_player.tingPaiList) if isTing then - --printlog("听牌提示===》》》",curIndex) - --pt(DataManager.CurrenRoom.self_player.tingPaiList[curIndex]) - local value=#DataManager.CurrenRoom.self_player.tingPaiList[curIndex].value - if tonumber(value)>0 then - card_view.btn_card:GetController("mark_ting").selectedIndex = 1 - end - - end - - end - - end - - - - + --printlog("听牌提示===》》》",curIndex) + --pt(DataManager.CurrenRoom.self_player.tingPaiList[curIndex]) + local value = #DataManager.CurrenRoom.self_player.tingPaiList[curIndex].value + if tonumber(value) > 0 then + card_view.btn_card:GetController("mark_ting").selectedIndex = 1 + end + end + end + end else - self._view :GetController("chupai").selectedIndex =0 - for k=1,#self.card_list do - local card_view= self.card_list[k] + self._view:GetController("chupai").selectedIndex = 0 + for k = 1, #self.card_list do + local card_view = self.card_list[k] card_view.btn_card:GetController("mark_ting").selectedIndex = 0 - end end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/hsrunbeard/EXGameController.lua b/lua_probject/extend_project/extend/zipai/hsrunbeard/EXGameController.lua index de6ee1ea..cb129fe5 100644 --- a/lua_probject/extend_project/extend/zipai/hsrunbeard/EXGameController.lua +++ b/lua_probject/extend_project/extend/zipai/hsrunbeard/EXGameController.lua @@ -5,15 +5,15 @@ local M = {} --- Create a new HZ_GameController function M.new() - setmetatable(M,{__index = GameController}) - local self = setmetatable({}, {__index = M}) - self:init("汉寿跑胡子") - self.class = "RB_GameController" - return self + setmetatable(M, { __index = GameController }) + local self = setmetatable({}, { __index = M }) + self:init("汉寿跑胡子") + self.class = "RB_GameController" + return self end function M:init(name) - GameController.init(self,name) + GameController.init(self, name) self._eventmap[RB_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards self._eventmap[RB_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn @@ -31,46 +31,44 @@ function M:init(name) self._eventmap[RB_Protocol.GAME_EVT_RESULT1] = self.OneventResult1 self._eventmap[RB_Protocol.GAME_EVT_QIPAI] = self.OnEventQIPAI self._eventmap[RB_Protocol.GAME_EVT_ADD_CARD] = self.OnAddCard - self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai - self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim - + self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai + self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim end function M:SendXiPaiAction(callBack) local _data = {} - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_XIPAI, _data) - self.XiPaiCallBack=callBack + self.XiPaiCallBack = callBack end function M:OnEventXiPai(evt_data) - if evt_data["result"]==0 then - if self.XiPaiCallBack then - self.XiPaiCallBack() - end - else - ViewUtil.ErrorTip(1000000,"申请洗牌失败") - end - + if evt_data["result"] == 0 then + if self.XiPaiCallBack then + self.XiPaiCallBack() + end + else + ViewUtil.ErrorTip(1000000, "申请洗牌失败") + end end function M:OnEventXiPaiAnim(evt_data) - printlog("洗牌动画===》》》》") - pt(evt_data) - local playeridList = evt_data["list"] - local isXiPai=false - if playeridList and #playeridList>0 then - for i=1,#playeridList do - local p = self._room:GetPlayerById(playeridList[i]) - if p== self._room.self_player then - isXiPai=true - end - end - end - - self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventXiPai,isXiPai) - end) + printlog("洗牌动画===》》》》") + pt(evt_data) + local playeridList = evt_data["list"] + local isXiPai = false + if playeridList and #playeridList > 0 then + for i = 1, #playeridList do + local p = self._room:GetPlayerById(playeridList[i]) + if p == self._room.self_player then + isXiPai = true + end + end + end + + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.EventXiPai, isXiPai) + end) end -- 发送出牌指令到服务器 @@ -78,25 +76,25 @@ function M:SendOutCard(card) local _data = {} _data["card"] = card local _room = self._room - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then _client:send(RB_Protocol.GAME_DIS_CARD, _data) end - end + --GAME_CHANGE_CARD GAME_DIS_CARD -function M:SendChangeCards( card_list ) +function M:SendChangeCards(card_list) local _data = {} if card_list then - _data["card_list"] = card_list - else - _data["card_list"]={} - end - local _client = ControllerManager.GameNetClinet + _data["card_list"] = card_list + else + _data["card_list"] = {} + end + local _client = ControllerManager.GameNetClinet if _client ~= nil then - printlog("SendChangeCards=======》》》") - pt(_data) - _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) + printlog("SendChangeCards=======》》》") + pt(_data) + _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) end end @@ -104,30 +102,29 @@ function M:SendChangeTypeFace(TypeFace) -- body local _data = {} _data["typeface"] = TypeFace - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) + _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) end end - -function M:ConformToNextGame( ) - local _client = ControllerManager.GameNetClinet +function M:ConformToNextGame() + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_EVT_CHUI) + _client:send(RB_Protocol.GAME_EVT_CHUI) end end -- 发送放子选择到服务器 -function M:SendAction(id,num) +function M:SendAction(id, num) local _data = {} _data["id"] = id - if num ~=nil then + if num ~= nil then _data["biid"] = num end local _client = ControllerManager.GameNetClinet - if _client ~= nil then - _client:send(RB_Protocol.GAME_ACTION, _data) + if _client ~= nil then + _client:send(RB_Protocol.GAME_ACTION, _data) end end @@ -137,28 +134,28 @@ function M:OnEventSendCards(evt_data) return end - local _room = self._room + local _room = self._room _room.curren_round = _room.curren_round + 1 if _room.curren_round > 0 then _room.playing = true end - - local handcards = {} - if evt_data.card_list and #evt_data.card_list>0 then - handcards = evt_data["card_list"] - else - ViewUtil.ErrorTip(100000,"发牌数据异常") - end - + + local handcards = {} + if evt_data.card_list and #evt_data.card_list > 0 then + handcards = evt_data["card_list"] + else + ViewUtil.ErrorTip(100000, "发牌数据异常") + end + local p = _room.self_player - local seat =nil - if evt_data.bank_seat then - seat = evt_data["bank_seat"] - else - ViewUtil.ErrorTip(100001,"发牌座位异常") - end - + local seat = nil + if evt_data.bank_seat then + seat = evt_data["bank_seat"] + else + ViewUtil.ErrorTip(100001, "发牌座位异常") + end + _room.banker_seat = seat - for i=1,#_room.player_list do - _room.self_player.handcard_list ={} + for i = 1, #_room.player_list do + _room.self_player.handcard_list = {} _room.self_player.card_list = {} _room.player_list[i].hand_left_count = 20 _room.player_list[i].fz_list = {} @@ -167,12 +164,12 @@ function M:OnEventSendCards(evt_data) _room.player_list[i].hu_xi = 0 end self._cacheEvent:Enqueue(function() - _room.self_player.handcard_list=handcards + _room.self_player.handcard_list = handcards self._room.self_player.hand_left_count = #handcards - DispatchEvent(self._dispatcher,RB_GameEvent.SendCards, p) - --print("发牌结束=====打开标志") - ControllerManager.IsSendCard=true - end) + DispatchEvent(self._dispatcher, RB_GameEvent.SendCards, p) + ---- print("发牌结束=====打开标志") + ControllerManager.IsSendCard = true + end) end function M:OnEventOutCard(evt_data) @@ -180,13 +177,13 @@ function M:OnEventOutCard(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(seat == _room.self_player.seat) then - list_remove(_room.self_player.handcard_list,card) + local _room = self._room + if (seat == _room.self_player.seat) then + list_remove(_room.self_player.handcard_list, card) end p.DiceCard = card - p.hand_left_count = p.hand_left_count -1 - DispatchEvent(self._dispatcher,RB_GameEvent.OutCard, p,card) + p.hand_left_count = p.hand_left_count - 1 + DispatchEvent(self._dispatcher, RB_GameEvent.OutCard, p, card) end) end @@ -195,10 +192,10 @@ function M:OnEventQIPAI(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(not p.outcard_list) then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card - DispatchEvent(self._dispatcher,RB_GameEvent.QiCard, seat,card) + local _room = self._room + if (not p.outcard_list) then p.outcard_list = {} end + p.outcard_list[#p.outcard_list + 1] = card + DispatchEvent(self._dispatcher, RB_GameEvent.QiCard, seat, card) end) end @@ -209,10 +206,10 @@ function M:OnEventTakeCard(evt_data) local left_count = evt_data["left_count"] local p = _room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - if card ~=0 then + if card ~= 0 then p.DiceCard = card end - DispatchEvent(self._dispatcher,RB_GameEvent.GetCard, seat, card, left_count) + DispatchEvent(self._dispatcher, RB_GameEvent.GetCard, seat, card, left_count) end) end @@ -221,55 +218,52 @@ function M:OnAddCard(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] local p = _room:GetPlayerBySeat(seat) - + self._cacheEvent:Enqueue(function() p.DiceCard = 0 - p.hand_left_count = p.hand_left_count +1 + p.hand_left_count = p.hand_left_count + 1 if (seat == _room.self_player.seat) then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - DispatchEvent(self._dispatcher,RB_GameEvent.AddCard, seat, card) + DispatchEvent(self._dispatcher, RB_GameEvent.AddCard, seat, card) end) end function M:OnEventOutHint(evt_data) - self._cacheEvent:Enqueue(function() - - DispatchEvent(self._dispatcher,RB_GameEvent.OutHint) + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.OutHint) end) - end function M:OnEventTurn(evt_data) local seat = evt_data["seat"] self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventTurn, seat) + DispatchEvent(self._dispatcher, RB_GameEvent.EventTurn, seat) end) end function M:OnEventFzTips(evt_data) self._cacheEvent:Enqueue(function() local tiplist = FZTipList.new() - local list = evt_data["tip_list"] - local uid = evt_data["uid"] - for i=1,#list do - local dtip = list[i] - local tip = {} - tip.id = dtip["id"] - tip.weight = dtip["weight"] - tip.card = dtip["card"] - tip.type = dtip["type"] - tip.bi_list = dtip["bi_list"] - if (dtip["opcard"]) then - local opcard = dtip["opcard"] - tip.OpCard = opcard - table.sort(tip.OpCard) - tip.OpCard[3] = tip.Card - end - tiplist:AddTip(tip) - + local list = evt_data["tip_list"] + local uid = evt_data["uid"] + for i = 1, #list do + local dtip = list[i] + local tip = {} + tip.id = dtip["id"] + tip.weight = dtip["weight"] + tip.card = dtip["card"] + tip.type = dtip["type"] + tip.bi_list = dtip["bi_list"] + if (dtip["opcard"]) then + local opcard = dtip["opcard"] + tip.OpCard = opcard + table.sort(tip.OpCard) + tip.OpCard[3] = tip.Card end - DispatchEvent(self._dispatcher,RB_GameEvent.FZTips, tiplist,uid) + tiplist:AddTip(tip) + end + DispatchEvent(self._dispatcher, RB_GameEvent.FZTips, tiplist, uid) end) end @@ -284,180 +278,172 @@ function M:OnEventFzAction(evt_data) local huxi = evt_data["hu_xi"] local p = _room:GetPlayerById(playerid) self._cacheEvent:Enqueue(function() - local isNeedDelHandCard =0 - p.hu_xi = huxi - local fz = {} - fz.card = card - fz.type = ftype - fz.active_card = actice_card - fz.from_seat = from_seat - fz.opcard =opcard - local remove_num = #opcard - if ftype == RB_FZType.Chi then - p.fz_list[#p.fz_list+1] = fz + local isNeedDelHandCard = 0 + p.hu_xi = huxi + local fz = {} + fz.card = card + fz.type = ftype + fz.active_card = actice_card + fz.from_seat = from_seat + fz.opcard = opcard + local remove_num = #opcard + if ftype == RB_FZType.Chi then + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Bi then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - list_remove(_room.self_player.handcard_list,fz.card) + list_remove(_room.self_player.handcard_list, fz.card) end elseif ftype == RB_FZType.Peng then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Kan then if (p == _room.self_player) then - if #opcard==2 then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + if #opcard == 2 then + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz end elseif ftype == RB_FZType.ChouWei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,2 do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, 2 do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Wei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Pao then - - if (p == _room.self_player) then - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) - end - end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Pao - end - end - local num =0 - for i=1,#_room.self_player.handcard_list do - if card == _room.self_player.handcard_list[i] then - num=num+1 - end - end - if num>0 then - isNeedDelHandCard =num - - for i=1,num do - list_remove(_room.self_player.handcard_list,card) - end - local isAddTi =false - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - isAddTi=true - remove_num= 0 - end - end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz - end - end - - else - local num =0 - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - num=1 - remove_num= 0 - end - end - if num==0 then - p.fz_list[#p.fz_list+1] = fz - end - end - - elseif ftype == RB_FZType.Ti then - if (p == _room.self_player) then - for i=1,#p.fz_list do + for i = 1, #p.fz_list do if p.fz_list[i].card == card then if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Ti + remove_num = 0 + p.fz_list[i].type = RB_FZType.Pao end end - local num =0 - for i=1,#_room.self_player.handcard_list do + local num = 0 + for i = 1, #_room.self_player.handcard_list do if card == _room.self_player.handcard_list[i] then - num=num+1 + num = num + 1 end end - if num>0 then - isNeedDelHandCard =num + if num > 0 then + isNeedDelHandCard = num - for i=1,num do - list_remove(_room.self_player.handcard_list,card) + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) end - local isAddTi =false - for i=1,#p.fz_list do + local isAddTi = false + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - isAddTi=true + p.fz_list[i].type = RB_FZType.Pao + isAddTi = true + remove_num = 0 end end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz end end - else - local num =0 - for i=1,#p.fz_list do + local num = 0 + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - num=1 + p.fz_list[i].type = RB_FZType.Pao + num = 1 + remove_num = 0 end end - if num==0 then - p.fz_list[#p.fz_list+1] = fz + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz end + end + elseif ftype == RB_FZType.Ti then + if (p == _room.self_player) then + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + if p.fz_list[i].type == RB_FZType.Kan then + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) + end + end + remove_num = 0 + p.fz_list[i].type = RB_FZType.Ti + end + end + local num = 0 + for i = 1, #_room.self_player.handcard_list do + if card == _room.self_player.handcard_list[i] then + num = num + 1 + end + end + if num > 0 then + isNeedDelHandCard = num - end - + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) + end + local isAddTi = false + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + isAddTi = true + end + end + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz + end + end + else + local num = 0 + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + num = 1 + end + end + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz + end + end end - + p.hand_left_count = p.hand_left_count - remove_num - if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then + if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then coroutine.start(function() coroutine.wait(0.5) - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) - end) - else - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) + end) + else + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) end - end) end @@ -465,12 +451,12 @@ function M:OnEventHu(evt_data) local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) - -- print(win_p.hand_left_count) - + -- -- print(win_p.hand_left_count) + self._cacheEvent:Enqueue(function() win_p.card_list = cards - table.sort( win_p.card_list, ViewUtil.HandCardSort) - DispatchEvent(self._dispatcher,RB_GameEvent.ZPHuCard, evt_data["seat"],evt_data["from_seat"],cards) + table.sort(win_p.card_list, ViewUtil.HandCardSort) + DispatchEvent(self._dispatcher, RB_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards) end) end @@ -486,17 +472,17 @@ function M:OneventResult1(evt_data) p.outcard_list = {} end self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult1, result); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult1, result); end) elseif 1 == over or 2 == over then DataManager.CurrenRoom.Over = true - ControllerManager.SetGameNetClient(nil,true) + ControllerManager.SetGameNetClient(nil, true) local total_result = evt_data.total_result local result = evt_data.result self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult2, result, total_result, over); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult2, result, total_result, over); end) end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/hsrunbeard/EXMainView.lua b/lua_probject/extend_project/extend/zipai/hsrunbeard/EXMainView.lua index c2cdfcf1..85604c5a 100644 --- a/lua_probject/extend_project/extend/zipai/hsrunbeard/EXMainView.lua +++ b/lua_probject/extend_project/extend/zipai/hsrunbeard/EXMainView.lua @@ -21,8 +21,8 @@ local Fix_Msg_Chat = { --- Create a new ZZ_MainView function M.new() - setmetatable(M, {__index = ZPMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = ZPMainView }) + local self = setmetatable({}, { __index = M }) self.class = 'RunBeard_MainView' self._full = true self:init() @@ -36,6 +36,7 @@ function M:getCardItem(card_1, card_2) return card_1 .. '2_' .. card_2 end end + function M:InitView(url) local _room = self._room self.Fix_Msg_Chat = Fix_Msg_Chat @@ -124,42 +125,40 @@ function M:NewPlayerCardInfoView(view, index) end return PlayerCardInfoView.new(view, self) end + function M:closeTipOnTuoguan() if self._clearingView ~= nil then self._clearingView:Close() end self:__CloseTip() end + function M:EventInit() MainView.EventInit(self) local _room = self._room local _view = self._view local _player_info = self._player_info local _gamectr = self._gamectr - - _gamectr:AddEventListener(GameEvent.EventXiPai,function( ... ) - local arg = {...} - local currentPlayer=arg[1] - - if ( currentPlayer ) then - self._popEvent = false - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - else - ViewUtil.ShowModalWait(self._root_view,"等待其它玩家洗牌...") - coroutine.start(function() - coroutine.wait(4) - ViewUtil.CloseModalWait() - end) - - - end - - - end) - + + _gamectr:AddEventListener(GameEvent.EventXiPai, function(...) + local arg = { ... } + local currentPlayer = arg[1] + + if (currentPlayer) then + self._popEvent = false + local xipaiCB = function() + self._popEvent = true + end + self:PlayXiPai(xipaiCB) + else + ViewUtil.ShowModalWait(self._root_view, "等待其它玩家洗牌...") + coroutine.start(function() + coroutine.wait(4) + ViewUtil.CloseModalWait() + end) + end + end) + _gamectr:AddEventListener( GameEvent.SendCards, function(...) @@ -206,7 +205,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.GetCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] local _leftcard = arg[3] @@ -232,7 +231,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.AddCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] self._popEvent = false @@ -253,7 +252,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.EventTurn, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local list = _room.player_list local readyNum = 0 @@ -285,7 +284,7 @@ function M:EventInit() function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -322,7 +321,7 @@ function M:EventInit() self:__CloseTip() self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] local p = _room:GetPlayerBySeat(seat) @@ -336,7 +335,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local _uid = arg[2] self:__FangziTip(_tip, _uid) @@ -351,7 +350,7 @@ function M:EventInit() self._left_time = 0 self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local w = arg[1] local l = arg[2] local cards = arg[3] @@ -387,7 +386,7 @@ function M:EventInit() function(...) self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -466,7 +465,7 @@ function M:EventInit() GameEvent.ZPResult2, function(...) self._left_time = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -496,10 +495,9 @@ end --改变牌队形 function M:ChangeCards(list) local _gamectr = ControllerManager.GetController(GameController) - if _gamectr then - _gamectr:SendChangeCards(list) - end - + if _gamectr then + _gamectr:SendChangeCards(list) + end end function M:__FangziTip(tip, _uid) @@ -523,12 +521,12 @@ function M:__FangziTip(tip, _uid) local td = tip.tip_map_type[_tlist[k]][1] local url = 'ui://Main_RunBeard/Btn_fztip' local btn_t = _lit_fanzi:AddItemFromPool(url) - if td.type==8 then - btn_t:GetChild("hupai").icon="ui://Main_RunBeard/201_1_" .. td.card - btn_t:GetController("hupai").selectedIndex=1 - end + if td.type == 8 then + btn_t:GetChild("hupai").icon = "ui://Main_RunBeard/201_1_" .. td.card + btn_t:GetController("hupai").selectedIndex = 1 + end btn_t.icon = 'ui://Main_RunBeard/newop_' .. td.type - btn_t.data = {tip, td, tip_hu} + btn_t.data = { tip, td, tip_hu } btn_t.onClick:Set(self.__TipAction, self) end if p.hand_left_count ~= 0 then @@ -561,6 +559,7 @@ function M:__FangziTip(tip, _uid) _chipeng_tip.x = _chipeng_tip.x + 200 _chipeng_tip.y = _chipeng_tip.y - 50 end + function M:__TipAction(context) local data = context.sender.data local _gamectr = self._gamectr @@ -749,7 +748,7 @@ function M:deepcopy(object) end function M:OnFangziAction(...) - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -842,7 +841,7 @@ function M:OnFangziAction(...) elseif fz.type == RB_FZType.Ti then self:PlaySound(player.self_user.sex, 'F_SaoChuan') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'ti') - -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti") + -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti") end effect.touchable = false effect.x, effect.y = 0, 0 @@ -874,7 +873,7 @@ function M:OnFangziAction(...) for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] - print(p.hu_xi) + -- print(p.hu_xi) info._view:GetChild('huxi').text = p.hu_xi end self._popEvent = true @@ -939,8 +938,8 @@ function M:ReloadRoom() card_info:ChuPaiTiShi() if self._room.self_player.card_list ~= nil and - #self._room.self_player.handcard_list == #self._room.self_player.card_list - then + #self._room.self_player.handcard_list == #self._room.self_player.card_list + then local _list = self:deepcopy(self._room.self_player.card_list) local cards = {} for i = 1, #_list do diff --git a/lua_probject/extend_project/extend/zipai/hsrunbeard/EXPlayBackView.lua b/lua_probject/extend_project/extend/zipai/hsrunbeard/EXPlayBackView.lua index 72e9a3cf..81fc8eb4 100644 --- a/lua_probject/extend_project/extend/zipai/hsrunbeard/EXPlayBackView.lua +++ b/lua_probject/extend_project/extend/zipai/hsrunbeard/EXPlayBackView.lua @@ -21,8 +21,8 @@ end --- Create a new function M.new() - setmetatable(M, {__index = PlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'PlayBackView' self:init() @@ -218,7 +218,7 @@ function M:ShowStep(index) info:UpdateQiPai(p.outcard_list) end end - -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) + -- -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) if step.cmd == Record_Event.Evt_result then local _room = DataManager.CurrenRoom local result = step.result @@ -323,6 +323,7 @@ function M:CmdGetCard(cmd, index) data.seat = cmd.seat data.DiceCard = cmd.data.card end + function M:CmdThrowCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -332,6 +333,7 @@ function M:CmdThrowCard(cmd, index) data.out_card_list = cmd.data.card u.outcard_list[#u.outcard_list + 1] = cmd.data.card end + function M:CmdAddCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd diff --git a/lua_probject/extend_project/extend/zipai/hsrunbeard/PlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/zipai/hsrunbeard/PlayerSelfCardInfoView.lua index 83ef722c..62c39a3a 100644 --- a/lua_probject/extend_project/extend/zipai/hsrunbeard/PlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/zipai/hsrunbeard/PlayerSelfCardInfoView.lua @@ -1,10 +1,10 @@ local PlayerSelfCardInfoView = require("main.zipai.ZPPlayerSelfCardInfoView") local CardCheck = require("main.zipai.CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(M, {__index = PlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(M, { __index = PlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -13,38 +13,36 @@ function M.new(view,mainView) return self end - function M:onTouchBegin(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local button = context.sender local card = button.data - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self:ShowHuTip(card.card_item) end - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", card.card_item) card.btn_card.sortingOrder = 100 - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - card.btn_card.xy = Vector2.New(card.btn_card.x+20 ,card.btn_card.y-50) + local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50) card.touch_pos = xy - button.xy - end function M:__OnDragEnd(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end local button = context.sender - + local card = button.data - + local _room = DataManager.CurrenRoom card.btn_card.sortingOrder = 0 - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y < -380 and _room.curren_outcard_seat == _room.self_player.seat) then button.touchable = false self.outcard_button = card @@ -53,7 +51,7 @@ function M:__OnDragEnd(context) else local isChangeCard = false self.outcard_button = nil - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_", card.card_item) self._area_handcard_list:AddChild(button) if #self.card_list == 1 then isChangeCard = false @@ -61,188 +59,184 @@ function M:__OnDragEnd(context) return end local CountCards = {} - for i=1,#self.card_list do + for i = 1, #self.card_list do local lists = {} if CountCards[self.card_list[i].index_X] == nil then - lists[#lists+1] = self.card_list[i] - CountCards[self.card_list[i].index_X]= lists + lists[#lists + 1] = self.card_list[i] + CountCards[self.card_list[i].index_X] = lists else - CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X]+1] =self.card_list[i] + CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X] + 1] = self.card_list[i] end end local minmark = 1 local maxmark = #self.card_list - if card == self.card_list[1] or card == self.card_list[#self.card_list] then + if card == self.card_list[1] or card == self.card_list[#self.card_list] then if self.card_list[1].index_X == self.card_list[2].index_X then - minmark =2 + minmark = 2 end - if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list-1].index_X then - maxmark =#self.card_list-1 + if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list - 1].index_X then + maxmark = #self.card_list - 1 end end - if button.x+button.width/2 < self.card_list[minmark].btn_card.x and #CountCards<10 then - list_remove(self.card_list,card) + if button.x + button.width / 2 < self.card_list[minmark].btn_card.x and #CountCards < 10 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X < card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X + 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X < card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X + 1 + end end else - for i=1,#self.card_list do - self.card_list[i].index_X = self.card_list[i].index_X + 1 + for i = 1, #self.card_list do + self.card_list[i].index_X = self.card_list[i].index_X + 1 end end - card.index_X =1 - card.index_Y =1 - table.insert(self.card_list,1,card) + card.index_X = 1 + card.index_Y = 1 + table.insert(self.card_list, 1, card) isChangeCard = true - elseif button.x+button.width/2 > (self.card_list[maxmark].btn_card.x +button.width) and #CountCards<10 then - list_remove(self.card_list,card) + elseif button.x + button.width / 2 > (self.card_list[maxmark].btn_card.x + button.width) and #CountCards < 10 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end end - card.index_X =self.card_list[#self.card_list].index_X+1 - card.index_Y =1 - self.card_list[#self.card_list+1] =card + card.index_X = self.card_list[#self.card_list].index_X + 1 + card.index_Y = 1 + self.card_list[#self.card_list + 1] = card isChangeCard = true - else + else local MoveCard = false local MoveCardPos = 0 local MoveCardY = 0 - for i=1,#CountCards do + for i = 1, #CountCards do local card_view = CountCards[i][1] - if card_view~=nil then - if button.x+button.width/2 > card_view.old_postion.x and button.x+button.width/2 < (card_view.old_postion.x+button.width) then - if card ~= card_view and #CountCards[i] <4 and card.index_X ~= card_view.index_X then - + if card_view ~= nil then + if button.x + button.width / 2 > card_view.old_postion.x and button.x + button.width / 2 < (card_view.old_postion.x + button.width) then + if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then MoveCardPos = i - MoveCardY = #CountCards[i]+1 + MoveCardY = #CountCards[i] + 1 MoveCard = true - list_remove(self.card_list,card) + list_remove(self.card_list, card) end end end end local MoveCardindex = 0 - -- local MoveCardY = 0 - if button.x+button.width/2 > card.old_postion.x and button.x+button.width/2 < (card.old_postion.x+button.width) then - if #CountCards[card.index_X]>1 then - for i=1,#CountCards[card.index_X] do + -- local MoveCardY = 0 + if button.x + button.width / 2 > card.old_postion.x and button.x + button.width / 2 < (card.old_postion.x + button.width) then + if #CountCards[card.index_X] > 1 then + for i = 1, #CountCards[card.index_X] do local _cv = CountCards[card.index_X][i] if _cv ~= card then - if button.y+button.height/2 > _cv.btn_card.y and button.y+button.height/2 < (_cv.btn_card.y+button.height) then + if button.y + button.height / 2 > _cv.btn_card.y and button.y + button.height / 2 < (_cv.btn_card.y + button.height) then --向下移動 - if ((button.y+button.height/2) +20) > (card.old_postion.y+button.height) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - --向上移動 - elseif ((button.y+button.height/2) -20) < card.old_postion.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - end - elseif i == #CountCards[card.index_X] and button.y+button.height/2 < _cv.btn_card.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - elseif i == 1 and button.y+button.height/2 > (_cv.btn_card.y+button.width) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) + if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + --向上移動 + elseif ((button.y + button.height / 2) - 20) < card.old_postion.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + end + elseif i == #CountCards[card.index_X] and button.y + button.height / 2 < _cv.btn_card.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + elseif i == 1 and button.y + button.height / 2 > (_cv.btn_card.y + button.width) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) end end end end - end - if MoveCard ==true and MoveCardindex ==0 then + if MoveCard == true and MoveCardindex == 0 then local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end if MoveCardPos > card.index_X then - MoveCardPos = MoveCardPos-1 + MoveCardPos = MoveCardPos - 1 end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do if MoveCardPos == self.card_list[i].index_X then - table.insert(self.card_list,(i+1),card) + table.insert(self.card_list, (i + 1), card) break end end isChangeCard = true - --上下移动 - elseif MoveCard ==true and MoveCardindex ~= 0 then - for i=1,#self.card_list do - if card.index_X == self.card_list[i].index_X then + --上下移动 + elseif MoveCard == true and MoveCardindex ~= 0 then + for i = 1, #self.card_list do + if card.index_X == self.card_list[i].index_X then --向下移动 if MoveCardindex == -1 then - if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then + if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then self.card_list[i].index_Y = self.card_list[i].index_Y + 1 - end - --向上移动 + --向上移动 else - if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 - + if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do - if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY-1) then - table.insert(self.card_list,(i+1),card) + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do + if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY - 1) then + table.insert(self.card_list, (i + 1), card) break - elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY+1) then - table.insert(self.card_list,i,card) + elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY + 1) then + table.insert(self.card_list, i, card) break end end @@ -251,176 +245,162 @@ function M:__OnDragEnd(context) isChangeCard = false self._area_handcard_list:AddChild(button) end - - end + end self:UpdateHandCardsPos() - if isChangeCard ==true then + if isChangeCard == true then self:SendChangeCard() end end end -function M:UpdateOutCardList(outcard,isShow,isMopai,seat) - if(isShow == nil) then - isShow = false +function M:UpdateOutCardList(outcard, isShow, isMopai, seat) + if (isShow == nil) then + isShow = false end - if(isMopai == nil) then - isMopai = false + if (isMopai == nil) then + isMopai = false end - self._area_outcard_list:RemoveChildren(0,-1,true) - local outcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") - - if outcard==0 then - outcards:GetChild("icon").icon ="ui://Main_RunBeard/202_1_300" + self._area_outcard_list:RemoveChildren(0, -1, true) + local outcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") + + if outcard == 0 then + outcards:GetChild("icon").icon = "ui://Main_RunBeard/202_1_300" else - outcards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/203_",outcard) + outcards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", outcard) end - outcards.x,outcards.y = 0,0 - local show_di_bg = outcards:GetChild("show_di_bg") - -- show_di_bg.visible = true - if(isShow)then - if outcard == 0 then - show_di_bg.visible = false - end - if(seat ~= nil and outcards~=nil)then - if(isMopai)then - if outcard ~= 0 then - outcards:GetTransition("mopai"..seat):Play(function( ) - -- show_di_bg.visible = true - - end) - end + outcards.x, outcards.y = 0, 0 + local show_di_bg = outcards:GetChild("show_di_bg") + -- show_di_bg.visible = true + if (isShow) then + if outcard == 0 then + show_di_bg.visible = false + end + if (seat ~= nil and outcards ~= nil) then + if (isMopai) then + if outcard ~= 0 then + outcards:GetTransition("mopai" .. seat):Play(function() + -- show_di_bg.visible = true + end) + end else - show_di_bg.visible = false - outcards:GetTransition("cpai"..seat):Play() + show_di_bg.visible = false + outcards:GetTransition("cpai" .. seat):Play() end - else - --show_di_bg.visible = true - end + else + --show_di_bg.visible = true + end else - show_di_bg.visible = false + show_di_bg.visible = false end self._area_outcard_list:AddChild(outcards) end --弃牌 -function M:UpdateQiPai( qi_list,isplay) - self._area_qipai_list:RemoveChildren(0,-1,true) - for i=1,#qi_list do - local qicards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") - qicards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/202_",qi_list[i]) - if(isplay)then - if(i == #qi_list) then - qicards:GetTransition("t0"):Play() +function M:UpdateQiPai(qi_list, isplay) + self._area_qipai_list:RemoveChildren(0, -1, true) + for i = 1, #qi_list do + local qicards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") + qicards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/202_", qi_list[i]) + if (isplay) then + if (i == #qi_list) then + qicards:GetTransition("t0"):Play() end - end - self._area_qipai_list:AddChild(qicards) - end + end + self._area_qipai_list:AddChild(qicards) + end end --摸牌动画 -function M:PlayingOutCardAnima( card) +function M:PlayingOutCardAnima(card) coroutine.start(function() - coroutine.wait(0.1) + coroutine.wait(0.1) self:ClearOutCard() end) end -function M:UpdateFzList( fz_list ,ispaly) - self._area_fz_list:RemoveChildren(0,-1,true) - for i = 1,#fz_list do - local fzitem=nil +function M:UpdateFzList(fz_list, ispaly) + self._area_fz_list:RemoveChildren(0, -1, true) + for i = 1, #fz_list do + local fzitem = nil if fz_list[i].type ~= RB_FZType.Kan then - fzitem =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") - if(ispaly == false)then - fzitem:RemoveChildren(0,-1,true) + fzitem = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") + if (ispaly == false) then + fzitem:RemoveChildren(0, -1, true) end end if fz_list[i].type == RB_FZType.Chi or fz_list[i].type == RB_FZType.Bi then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetChild("card_"..1).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].active_card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetChild("card_" .. 1).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].active_card) fzcards:GetController("c2").selectedIndex = 1 - fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[1]) - fzcards:GetChild("card_"..3).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[2]) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 2).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[1]) + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[2]) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Peng then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Wei then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetController("c1").selectedIndex=1 - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetController("c1").selectedIndex = 1 + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.ChouWei then - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,2 do - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 2 do + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end - fzcards:GetChild("card_"..3).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Pao then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Ti then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - if j==4 then - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + if j == 4 then + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) else - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) end end end - -function M:playAnim( fzitem,fzcards, size,i,ispaly ) - if(ispaly == nil)then - ispaly =false - end - if(ispaly and i == size)then - local faArray= fzitem:GetChild("chiwei") - if(faArray~=nil)then - faArray:AddChild(fzcards) - else - fzitem:AddChild(fzcards) - end - else - fzitem:AddChild(fzcards) - end - self._area_fz_list:AddChild(fzitem) +function M:playAnim(fzitem, fzcards, size, i, ispaly) + if (ispaly == nil) then + ispaly = false + end + if (ispaly and i == size) then + local faArray = fzitem:GetChild("chiwei") + if (faArray ~= nil) then + faArray:AddChild(fzcards) + else + fzitem:AddChild(fzcards) + end + else + fzitem:AddChild(fzcards) + end + self._area_fz_list:AddChild(fzitem) end - - --出牌提示动画 - function M:ChuPaiTiShi() - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then +--出牌提示动画 +function M:ChuPaiTiShi() + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local chu_player = DataManager.CurrenRoom.self_player @@ -431,32 +411,31 @@ end selfplayeTable.paoCount = chu_player.paoCount selfplayeTable.hu_xi = chu_player.hu_xi local player = membe_deep_clone(selfplayeTable) - local mark_ting= {} - for i=1,#DataManager.CurrenRoom.self_player.handcard_list do - local card = DataManager.CurrenRoom.self_player.handcard_list[i] + local mark_ting = {} + for i = 1, #DataManager.CurrenRoom.self_player.handcard_list do + local card = DataManager.CurrenRoom.self_player.handcard_list[i] list_remove(player.handcard_list, card) local _player = membe_deep_clone(player) - local tingList = CardCheck.tingPai(_player,DataManager.CurrenRoom) + local tingList = CardCheck.tingPai(_player, DataManager.CurrenRoom) local isKan = false - for j=1,#player.fz_list do + for j = 1, #player.fz_list do if card == player.fz_list[j].card and player.fz_list[j].type == RB_FZType.Kan then - isKan =true + isKan = true end end if #tingList > 0 and isKan == false then - - mark_ting[#mark_ting+1] = card + mark_ting[#mark_ting + 1] = card end table.insert(player.handcard_list, card) - table.sort( player.handcard_list, ViewUtil.HandCardSort) + table.sort(player.handcard_list, ViewUtil.HandCardSort) end - -- print("ChuPaiTiShi",#mark_ting,vardump(player)) - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then - self._view :GetController("chupai").selectedIndex =1 - if #mark_ting>0 then - for i=1,#mark_ting do - for k=1,#self.card_list do - local card_view= self.card_list[k] + -- -- print("ChuPaiTiShi",#mark_ting,vardump(player)) + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + self._view:GetController("chupai").selectedIndex = 1 + if #mark_ting > 0 then + for i = 1, #mark_ting do + for k = 1, #self.card_list do + local card_view = self.card_list[k] if card_view.card_item == mark_ting[i] then card_view.btn_card:GetController("mark_ting").selectedIndex = 1 end @@ -464,13 +443,12 @@ end end end else - self._view :GetController("chupai").selectedIndex =0 - for k=1,#self.card_list do - local card_view= self.card_list[k] + self._view:GetController("chupai").selectedIndex = 0 + for k = 1, #self.card_list do + local card_view = self.card_list[k] card_view.btn_card:GetController("mark_ting").selectedIndex = 0 - end end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/runbeard/EXGameController.lua b/lua_probject/extend_project/extend/zipai/runbeard/EXGameController.lua index 9fa35c56..0a7c0ecb 100644 --- a/lua_probject/extend_project/extend/zipai/runbeard/EXGameController.lua +++ b/lua_probject/extend_project/extend/zipai/runbeard/EXGameController.lua @@ -5,15 +5,15 @@ local M = {} --- Create a new HZ_GameController function M.new() - setmetatable(M,{__index = GameController}) - local self = setmetatable({}, {__index = M}) - self:init("湘潭跑胡子") - self.class = "RB_GameController" - return self + setmetatable(M, { __index = GameController }) + local self = setmetatable({}, { __index = M }) + self:init("湘潭跑胡子") + self.class = "RB_GameController" + return self end function M:init(name) - GameController.init(self,name) + GameController.init(self, name) self._eventmap[RB_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards self._eventmap[RB_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn @@ -30,52 +30,48 @@ function M:init(name) self._eventmap[RB_Protocol.GAME_EVT_FANGWEI] = self.OnEventFangWei self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai - self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim + self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim self._eventmap[RB_Protocol.GAME_EVT_RESULT1] = self.OneventResult1 self._eventmap[RB_Protocol.GAME_EVT_QIPAI] = self.OnEventQIPAI self._eventmap[RB_Protocol.GAME_EVT_ADD_CARD] = self.OnAddCard - end function M:SendXiPaiAction(callBack) - local _data = {} - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_XIPAI, _data) - self.XiPaiCallBack=callBack + self.XiPaiCallBack = callBack end function M:OnEventXiPai(evt_data) - - if evt_data["result"]==0 then - if self.XiPaiCallBack then - self.XiPaiCallBack() - end - else - ViewUtil.ErrorTip(1000000,"申请洗牌失败") - end - + if evt_data["result"] == 0 then + if self.XiPaiCallBack then + self.XiPaiCallBack() + end + else + ViewUtil.ErrorTip(1000000, "申请洗牌失败") + end end function M:OnEventXiPaiAnim(evt_data) - local playeridList = evt_data["list"] - local isXiPai=false + local playeridList = evt_data["list"] + local isXiPai = false local otherisXiPai = false - if playeridList and #playeridList>0 then - for i=1,#playeridList do - local p = self._room:GetPlayerById(playeridList[i]) - if p== self._room.self_player then - isXiPai=true - else - otherisXiPai=true - end - end - end - - self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventXiPai,isXiPai,otherisXiPai) - end) + if playeridList and #playeridList > 0 then + for i = 1, #playeridList do + local p = self._room:GetPlayerById(playeridList[i]) + if p == self._room.self_player then + isXiPai = true + else + otherisXiPai = true + end + end + end + + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.EventXiPai, isXiPai, otherisXiPai) + end) end -- 发送出牌指令到服务器 @@ -83,36 +79,36 @@ function M:SendOutCard(card) local _data = {} _data["card"] = card local _room = self._room - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then _client:send(RB_Protocol.GAME_DIS_CARD, _data) end - end + --GAME_CHANGE_CARD GAME_DIS_CARD -function M:SendChangeCards( card_list ) +function M:SendChangeCards(card_list) local _data = {} - if card_list then - _data["card_list"] = card_list - else - _data["card_list"]={} - end - local _client = ControllerManager.GameNetClinet + if card_list then + _data["card_list"] = card_list + else + _data["card_list"] = {} + end + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) + _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) end end function M:SendFangPao(card) local _data = {} - if card then - _data["card"] = card - else - _data["card"]={} - end - local _client = ControllerManager.GameNetClinet + if card then + _data["card"] = card + else + _data["card"] = {} + end + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_EVT_FANGPAO, _data) + _client:send(RB_Protocol.GAME_EVT_FANGPAO, _data) end end @@ -120,30 +116,29 @@ function M:SendChangeTypeFace(TypeFace) -- body local _data = {} _data["typeface"] = TypeFace - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) + _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) end end - -function M:ConformToNextGame( ) - local _client = ControllerManager.GameNetClinet +function M:ConformToNextGame() + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_EVT_CHUI) + _client:send(RB_Protocol.GAME_EVT_CHUI) end end -- 发送放子选择到服务器 -function M:SendAction(id,num) +function M:SendAction(id, num) local _data = {} _data["id"] = id - if num ~=nil then + if num ~= nil then _data["biid"] = num end local _client = ControllerManager.GameNetClinet - if _client ~= nil then - _client:send(RB_Protocol.GAME_ACTION, _data) + if _client ~= nil then + _client:send(RB_Protocol.GAME_ACTION, _data) end end @@ -154,25 +149,26 @@ function M:OnEventSendCards(evt_data) return end - local _room = self._room + local _room = self._room _room.curren_round = _room.curren_round + 1 if _room.curren_round > 0 then _room.playing = true end - local handcards = {} - if evt_data.card_list and #evt_data.card_list>0 then - handcards = evt_data["card_list"] - else - ViewUtil.ErrorTip(100000,"发牌数据异常") - end - + local handcards = {} + if evt_data.card_list and #evt_data.card_list > 0 then + handcards = evt_data["card_list"] + else + ViewUtil.ErrorTip(100000, "发牌数据异常") + end + local p = _room.self_player - local seat =nil - if evt_data.bank_seat then - seat = evt_data["bank_seat"] - else - ViewUtil.ErrorTip(100001,"发牌座位异常") - end _room.banker_seat = seat - for i=1,#_room.player_list do - _room.self_player.handcard_list ={} + local seat = nil + if evt_data.bank_seat then + seat = evt_data["bank_seat"] + else + ViewUtil.ErrorTip(100001, "发牌座位异常") + end + _room.banker_seat = seat + for i = 1, #_room.player_list do + _room.self_player.handcard_list = {} _room.self_player.card_list = {} _room.player_list[i].hand_left_count = 20 _room.player_list[i].fz_list = {} @@ -181,28 +177,28 @@ function M:OnEventSendCards(evt_data) _room.player_list[i].hu_xi = 0 end self._cacheEvent:Enqueue(function() - _room.self_player.handcard_list=handcards + _room.self_player.handcard_list = handcards self._room.self_player.hand_left_count = #handcards - DispatchEvent(self._dispatcher,RB_GameEvent.SendCards, p) - ControllerManager.IsSendCard=true - end) + DispatchEvent(self._dispatcher, RB_GameEvent.SendCards, p) + ControllerManager.IsSendCard = true + end) end function M:OnEventOutCard(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] - printlog("jefe OnEventOutCard>>>>",card) + printlog("jefe OnEventOutCard>>>>", card) -- 判断是否对方有偎 - + local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(seat == _room.self_player.seat) then - list_remove(_room.self_player.handcard_list,card) + local _room = self._room + if (seat == _room.self_player.seat) then + list_remove(_room.self_player.handcard_list, card) end p.DiceCard = card - p.hand_left_count = p.hand_left_count -1 - DispatchEvent(self._dispatcher,RB_GameEvent.OutCard, p,card) + p.hand_left_count = p.hand_left_count - 1 + DispatchEvent(self._dispatcher, RB_GameEvent.OutCard, p, card) end) end @@ -211,10 +207,10 @@ function M:OnEventQIPAI(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(not p.outcard_list) then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card - DispatchEvent(self._dispatcher,RB_GameEvent.QiCard, seat,card) + local _room = self._room + if (not p.outcard_list) then p.outcard_list = {} end + p.outcard_list[#p.outcard_list + 1] = card + DispatchEvent(self._dispatcher, RB_GameEvent.QiCard, seat, card) end) end @@ -225,10 +221,10 @@ function M:OnEventTakeCard(evt_data) local left_count = evt_data["left_count"] local p = _room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - if card ~=0 then + if card ~= 0 then p.DiceCard = card end - DispatchEvent(self._dispatcher,RB_GameEvent.GetCard, seat, card, left_count) + DispatchEvent(self._dispatcher, RB_GameEvent.GetCard, seat, card, left_count) end) end @@ -237,60 +233,57 @@ function M:OnAddCard(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] local p = _room:GetPlayerBySeat(seat) - + self._cacheEvent:Enqueue(function() p.DiceCard = 0 - p.hand_left_count = p.hand_left_count +1 + p.hand_left_count = p.hand_left_count + 1 if (seat == _room.self_player.seat) then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - DispatchEvent(self._dispatcher,RB_GameEvent.AddCard, seat, card) + DispatchEvent(self._dispatcher, RB_GameEvent.AddCard, seat, card) end) end function M:OnEventOutHint(evt_data) printlog("jefe OutHint 提示===>>>>") self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.OutHint) + DispatchEvent(self._dispatcher, RB_GameEvent.OutHint) end) - end function M:OnEventTurn(evt_data) local seat = evt_data["seat"] self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventTurn, seat) + DispatchEvent(self._dispatcher, RB_GameEvent.EventTurn, seat) end) end function M:OnEventFzTips(evt_data) - self._cacheEvent:Enqueue(function() local tiplist = FZTipList.new() - local list = evt_data["tip_list"] - local uid = evt_data["uid"] + local list = evt_data["tip_list"] + local uid = evt_data["uid"] local fptype = evt_data['fptype'] - for i=1,#list do - local dtip = list[i] - local tip = {} - tip.id = dtip["id"] - - -- if false then - tip.weight = dtip["weight"] - tip.card = dtip["card"] - tip.type = dtip["type"] - tip.bi_list = dtip["bi_list"] - if (dtip["opcard"]) then - local opcard = dtip["opcard"] - tip.OpCard = opcard - table.sort(tip.OpCard) - tip.OpCard[3] = tip.Card - end - tiplist:AddTip(tip) - -- end - + for i = 1, #list do + local dtip = list[i] + local tip = {} + tip.id = dtip["id"] + + -- if false then + tip.weight = dtip["weight"] + tip.card = dtip["card"] + tip.type = dtip["type"] + tip.bi_list = dtip["bi_list"] + if (dtip["opcard"]) then + local opcard = dtip["opcard"] + tip.OpCard = opcard + table.sort(tip.OpCard) + tip.OpCard[3] = tip.Card end - DispatchEvent(self._dispatcher,RB_GameEvent.FZTips, tiplist,uid,fptype) + tiplist:AddTip(tip) + -- end + end + DispatchEvent(self._dispatcher, RB_GameEvent.FZTips, tiplist, uid, fptype) end) end @@ -298,10 +291,10 @@ end function M:OnEventFangWei(evt_data) printlog("jefe fangwei 提示===>>>>") pt(evt_data) - local seat = evt_data["seat"] - local card = evt_data["card"] + local seat = evt_data["seat"] + local card = evt_data["card"] self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.FangWei,seat,card) + DispatchEvent(self._dispatcher, RB_GameEvent.FangWei, seat, card) end) end @@ -317,180 +310,172 @@ function M:OnEventFzAction(evt_data) local huxi = evt_data["hu_xi"] local p = _room:GetPlayerById(playerid) self._cacheEvent:Enqueue(function() - local isNeedDelHandCard =0 - p.hu_xi = huxi - local fz = {} - fz.card = card - fz.type = ftype - fz.active_card = actice_card - fz.from_seat = from_seat - fz.opcard =opcard - local remove_num = #opcard - if ftype == RB_FZType.Chi then - p.fz_list[#p.fz_list+1] = fz + local isNeedDelHandCard = 0 + p.hu_xi = huxi + local fz = {} + fz.card = card + fz.type = ftype + fz.active_card = actice_card + fz.from_seat = from_seat + fz.opcard = opcard + local remove_num = #opcard + if ftype == RB_FZType.Chi then + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Bi then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - list_remove(_room.self_player.handcard_list,fz.card) + list_remove(_room.self_player.handcard_list, fz.card) end elseif ftype == RB_FZType.Peng then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Kan then if (p == _room.self_player) then - if #opcard==2 then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + if #opcard == 2 then + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz end elseif ftype == RB_FZType.ChouWei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,2 do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, 2 do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Wei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Pao then - - if (p == _room.self_player) then - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) - end - end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Pao - end - end - local num =0 - for i=1,#_room.self_player.handcard_list do - if card == _room.self_player.handcard_list[i] then - num=num+1 - end - end - if num>0 then - isNeedDelHandCard =num - - for i=1,num do - list_remove(_room.self_player.handcard_list,card) - end - local isAddTi =false - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - isAddTi=true - remove_num= 0 - end - end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz - end - end - - else - local num =0 - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - num=1 - remove_num= 0 - end - end - if num==0 then - p.fz_list[#p.fz_list+1] = fz - end - end - - elseif ftype == RB_FZType.Ti then - if (p == _room.self_player) then - for i=1,#p.fz_list do + for i = 1, #p.fz_list do if p.fz_list[i].card == card then if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Ti + remove_num = 0 + p.fz_list[i].type = RB_FZType.Pao end end - local num =0 - for i=1,#_room.self_player.handcard_list do + local num = 0 + for i = 1, #_room.self_player.handcard_list do if card == _room.self_player.handcard_list[i] then - num=num+1 + num = num + 1 end end - if num>0 then - isNeedDelHandCard =num + if num > 0 then + isNeedDelHandCard = num - for i=1,num do - list_remove(_room.self_player.handcard_list,card) + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) end - local isAddTi =false - for i=1,#p.fz_list do + local isAddTi = false + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - isAddTi=true + p.fz_list[i].type = RB_FZType.Pao + isAddTi = true + remove_num = 0 end end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz end end - else - local num =0 - for i=1,#p.fz_list do + local num = 0 + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - num=1 + p.fz_list[i].type = RB_FZType.Pao + num = 1 + remove_num = 0 end end - if num==0 then - p.fz_list[#p.fz_list+1] = fz + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz end + end + elseif ftype == RB_FZType.Ti then + if (p == _room.self_player) then + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + if p.fz_list[i].type == RB_FZType.Kan then + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) + end + end + remove_num = 0 + p.fz_list[i].type = RB_FZType.Ti + end + end + local num = 0 + for i = 1, #_room.self_player.handcard_list do + if card == _room.self_player.handcard_list[i] then + num = num + 1 + end + end + if num > 0 then + isNeedDelHandCard = num - end - + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) + end + local isAddTi = false + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + isAddTi = true + end + end + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz + end + end + else + local num = 0 + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + num = 1 + end + end + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz + end + end end - + p.hand_left_count = p.hand_left_count - remove_num - if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then + if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then coroutine.start(function() coroutine.wait(0.5) - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) - end) - else - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) + end) + else + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) end - end) end @@ -498,12 +483,12 @@ function M:OnEventHu(evt_data) local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) - -- print(win_p.hand_left_count) - + -- -- print(win_p.hand_left_count) + self._cacheEvent:Enqueue(function() win_p.card_list = cards - table.sort( win_p.card_list, ViewUtil.HandCardSort) - DispatchEvent(self._dispatcher,RB_GameEvent.ZPHuCard, evt_data["seat"],evt_data["from_seat"],cards) + table.sort(win_p.card_list, ViewUtil.HandCardSort) + DispatchEvent(self._dispatcher, RB_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards) end) end @@ -519,17 +504,17 @@ function M:OneventResult1(evt_data) p.outcard_list = {} end self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult1, result); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult1, result); end) elseif 1 == over or 2 == over then DataManager.CurrenRoom.Over = true - ControllerManager.SetGameNetClient(nil,true) + ControllerManager.SetGameNetClient(nil, true) local total_result = evt_data.total_result local result = evt_data.result self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult2, result, total_result, over); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult2, result, total_result, over); end) end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/runbeard/EXPlayBackView.lua b/lua_probject/extend_project/extend/zipai/runbeard/EXPlayBackView.lua index a6fe3209..6cd7f122 100644 --- a/lua_probject/extend_project/extend/zipai/runbeard/EXPlayBackView.lua +++ b/lua_probject/extend_project/extend/zipai/runbeard/EXPlayBackView.lua @@ -21,8 +21,8 @@ end --- Create a new function M.new() - setmetatable(M, {__index = PlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'PlayBackView' self:init() @@ -137,15 +137,13 @@ function M:FillRoomData(data) infoHand:UpdateScore() end end - self.CheckServerErrorList={} + self.CheckServerErrorList = {} self:UpdateRound(self._room.curren_round) self:GenerateAllStepData(data) self:ShowStep(1) self:UpdateStep(1) end - - function M:ShowStep(index) local step = self._step[index + 1] self:UpdateStep(index + 1) @@ -181,21 +179,20 @@ function M:ShowStep(index) info:UpdateFzList(p.fz_list) end end - - if index>1 then - for k,v in pairs(self.CheckServerErrorList) do - --printlog("k===>>>",k) - --printlog("v===>>>",v) - --printlog(k,index) - --pt(p.card_list) - if tonumber(index+1)>tonumber(k) then - list_remove(p.card_list,v) - end - - end - end - - + + if index > 1 then + for k, v in pairs(self.CheckServerErrorList) do + --printlog("k===>>>",k) + --printlog("v===>>>",v) + --printlog(k,index) + --pt(p.card_list) + if tonumber(index + 1) > tonumber(k) then + list_remove(p.card_list, v) + end + end + end + + if p.seat ~= self._room.self_player.seat then info:InitHandCard(p.card_list) @@ -203,11 +200,11 @@ function M:ShowStep(index) self._room.self_player.handcard_list = p.card_list info:InitHandCard(false) end - - - - --if p.seat == self._room.self_player.seat then + + + + --if p.seat == self._room.self_player.seat then --[[if step.cmd == Record_Event.Evt_ChangePaiXing then local _card_list = {} for i = 1, #step.card_list do @@ -224,8 +221,8 @@ function M:ShowStep(index) info:UpdateHandCards(step.card_list) end end--]] - --end - + --end + if step.cmd == Record_Event.Evt_OutCard or step.cmd == Record_Event.Evt_GetCard then if step.DiceCard ~= nil and step.DiceCard ~= 0 then if p.seat == step.seat then @@ -243,7 +240,7 @@ function M:ShowStep(index) info:UpdateQiPai(p.outcard_list) end end - -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) + -- -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) if step.cmd == Record_Event.Evt_result then local _room = DataManager.CurrenRoom local result = step.result @@ -303,11 +300,11 @@ end function M:GenerateAllStepData(data) local cmdList = self.cmdList - --pt(cmdList) + --pt(cmdList) self._step = {} local step = {} local info = data.info - --pt(info) + --pt(info) step.cmd = '' step.left_card = info.left_card step.win = 0 @@ -350,6 +347,7 @@ function M:CmdGetCard(cmd, index) data.seat = cmd.seat data.DiceCard = cmd.data.card end + function M:CmdThrowCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -359,14 +357,15 @@ function M:CmdThrowCard(cmd, index) data.out_card_list = cmd.data.card u.outcard_list[#u.outcard_list + 1] = cmd.data.card end + function M:CmdAddCard(cmd, index) - --printlog("CmdAddCard======>>>",index,cmd.data.card) + --printlog("CmdAddCard======>>>",index,cmd.data.card) local data = self:CopyLastStep(index) data.cmd = cmd.cmd local _room = self._room local u = data.player_card_data[cmd.seat] u.card_list[#u.card_list + 1] = cmd.data.card - --pt(u.card_list) + --pt(u.card_list) end function M:onResult(cmd, index) @@ -458,11 +457,11 @@ function M:CmdAction(cmd, index) num = num + 1 end end - --table.insert(self.CheckServerErrorList,card) - if self.CheckServerErrorList==nil then - self.CheckServerErrorList={} - end - self.CheckServerErrorList[index]=card + --table.insert(self.CheckServerErrorList,card) + if self.CheckServerErrorList == nil then + self.CheckServerErrorList = {} + end + self.CheckServerErrorList[index] = card local isAddTi = false for i = 1, #p.fz_list do if p.fz_list[i].card == card then @@ -510,7 +509,7 @@ function M:CopyLastStep(index) card_data[i].hand_left_count = #card_data[i].card_list card_data[i].hu_xi = self:deepcopy(last_step.player_card_data[i].hu_xi) end - --pt(card_data) + --pt(card_data) self._step[#self._step + 1] = step return step end @@ -535,7 +534,7 @@ function M:deepcopy(object) end function M:NextRecordPlay() - printlog("NextRecordPlay") + printlog("NextRecordPlay") local result = PlayBackView.NextRecordPlay(self) if not result then return @@ -547,7 +546,7 @@ function M:NextRecordPlay() end function M:LastRecordPlay() - printlog("LastRecordPlay") + printlog("LastRecordPlay") local result = PlayBackView.LastRecordPlay(self) if not result then return diff --git a/lua_probject/extend_project/extend/zipai/runbeard/PlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/zipai/runbeard/PlayerSelfCardInfoView.lua index 584a2e9d..c9552eac 100644 --- a/lua_probject/extend_project/extend/zipai/runbeard/PlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/zipai/runbeard/PlayerSelfCardInfoView.lua @@ -1,10 +1,10 @@ local PlayerSelfCardInfoView = require("main.zipai.ZPPlayerSelfCardInfoView") local CardCheck = require("main.zipai.CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(M, {__index = PlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(M, { __index = PlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -13,38 +13,36 @@ function M.new(view,mainView) return self end - function M:onTouchBegin(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local button = context.sender local card = button.data - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self:ShowHuTip(card.card_item) end - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", card.card_item) card.btn_card.sortingOrder = 100 - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - card.btn_card.xy = Vector2.New(card.btn_card.x+20 ,card.btn_card.y-50) + local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50) card.touch_pos = xy - button.xy - end function M:__OnDragEnd(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end local button = context.sender - + local card = button.data - + local _room = DataManager.CurrenRoom card.btn_card.sortingOrder = 0 - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y < -380 and _room.curren_outcard_seat == _room.self_player.seat) then button.touchable = false self.outcard_button = card @@ -53,7 +51,7 @@ function M:__OnDragEnd(context) else local isChangeCard = false self.outcard_button = nil - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_", card.card_item) self._area_handcard_list:AddChild(button) if #self.card_list == 1 then isChangeCard = false @@ -61,188 +59,184 @@ function M:__OnDragEnd(context) return end local CountCards = {} - for i=1,#self.card_list do + for i = 1, #self.card_list do local lists = {} if CountCards[self.card_list[i].index_X] == nil then - lists[#lists+1] = self.card_list[i] - CountCards[self.card_list[i].index_X]= lists + lists[#lists + 1] = self.card_list[i] + CountCards[self.card_list[i].index_X] = lists else - CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X]+1] =self.card_list[i] + CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X] + 1] = self.card_list[i] end end local minmark = 1 local maxmark = #self.card_list - if card == self.card_list[1] or card == self.card_list[#self.card_list] then + if card == self.card_list[1] or card == self.card_list[#self.card_list] then if self.card_list[1].index_X == self.card_list[2].index_X then - minmark =2 + minmark = 2 end - if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list-1].index_X then - maxmark =#self.card_list-1 + if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list - 1].index_X then + maxmark = #self.card_list - 1 end end - if button.x+button.width/2 < self.card_list[minmark].btn_card.x and #CountCards<10 then - list_remove(self.card_list,card) + if button.x + button.width / 2 < self.card_list[minmark].btn_card.x and #CountCards < 10 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X < card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X + 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X < card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X + 1 + end end else - for i=1,#self.card_list do - self.card_list[i].index_X = self.card_list[i].index_X + 1 + for i = 1, #self.card_list do + self.card_list[i].index_X = self.card_list[i].index_X + 1 end end - card.index_X =1 - card.index_Y =1 - table.insert(self.card_list,1,card) + card.index_X = 1 + card.index_Y = 1 + table.insert(self.card_list, 1, card) isChangeCard = true - elseif button.x+button.width/2 > (self.card_list[maxmark].btn_card.x +button.width) and #CountCards<10 then - list_remove(self.card_list,card) + elseif button.x + button.width / 2 > (self.card_list[maxmark].btn_card.x + button.width) and #CountCards < 10 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end end - card.index_X =self.card_list[#self.card_list].index_X+1 - card.index_Y =1 - self.card_list[#self.card_list+1] =card + card.index_X = self.card_list[#self.card_list].index_X + 1 + card.index_Y = 1 + self.card_list[#self.card_list + 1] = card isChangeCard = true - else + else local MoveCard = false local MoveCardPos = 0 local MoveCardY = 0 - for i=1,#CountCards do + for i = 1, #CountCards do local card_view = CountCards[i][1] - if card_view~=nil then - if button.x+button.width/2 > card_view.old_postion.x and button.x+button.width/2 < (card_view.old_postion.x+button.width) then - if card ~= card_view and #CountCards[i] <4 and card.index_X ~= card_view.index_X then - + if card_view ~= nil then + if button.x + button.width / 2 > card_view.old_postion.x and button.x + button.width / 2 < (card_view.old_postion.x + button.width) then + if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then MoveCardPos = i - MoveCardY = #CountCards[i]+1 + MoveCardY = #CountCards[i] + 1 MoveCard = true - list_remove(self.card_list,card) + list_remove(self.card_list, card) end end end end local MoveCardindex = 0 - -- local MoveCardY = 0 - if button.x+button.width/2 > card.old_postion.x and button.x+button.width/2 < (card.old_postion.x+button.width) then - if #CountCards[card.index_X]>1 then - for i=1,#CountCards[card.index_X] do + -- local MoveCardY = 0 + if button.x + button.width / 2 > card.old_postion.x and button.x + button.width / 2 < (card.old_postion.x + button.width) then + if #CountCards[card.index_X] > 1 then + for i = 1, #CountCards[card.index_X] do local _cv = CountCards[card.index_X][i] if _cv ~= card then - if button.y+button.height/2 > _cv.btn_card.y and button.y+button.height/2 < (_cv.btn_card.y+button.height) then + if button.y + button.height / 2 > _cv.btn_card.y and button.y + button.height / 2 < (_cv.btn_card.y + button.height) then --向下移動 - if ((button.y+button.height/2) +20) > (card.old_postion.y+button.height) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - --向上移動 - elseif ((button.y+button.height/2) -20) < card.old_postion.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - end - elseif i == #CountCards[card.index_X] and button.y+button.height/2 < _cv.btn_card.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - elseif i == 1 and button.y+button.height/2 > (_cv.btn_card.y+button.width) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) + if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + --向上移動 + elseif ((button.y + button.height / 2) - 20) < card.old_postion.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + end + elseif i == #CountCards[card.index_X] and button.y + button.height / 2 < _cv.btn_card.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + elseif i == 1 and button.y + button.height / 2 > (_cv.btn_card.y + button.width) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) end end end end - end - if MoveCard ==true and MoveCardindex ==0 then + if MoveCard == true and MoveCardindex == 0 then local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end if MoveCardPos > card.index_X then - MoveCardPos = MoveCardPos-1 + MoveCardPos = MoveCardPos - 1 end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do if MoveCardPos == self.card_list[i].index_X then - table.insert(self.card_list,(i+1),card) + table.insert(self.card_list, (i + 1), card) break end end isChangeCard = true - --上下移动 - elseif MoveCard ==true and MoveCardindex ~= 0 then - for i=1,#self.card_list do - if card.index_X == self.card_list[i].index_X then + --上下移动 + elseif MoveCard == true and MoveCardindex ~= 0 then + for i = 1, #self.card_list do + if card.index_X == self.card_list[i].index_X then --向下移动 if MoveCardindex == -1 then - if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then + if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then self.card_list[i].index_Y = self.card_list[i].index_Y + 1 - end - --向上移动 + --向上移动 else - if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 - + if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do - if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY-1) then - table.insert(self.card_list,(i+1),card) + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do + if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY - 1) then + table.insert(self.card_list, (i + 1), card) break - elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY+1) then - table.insert(self.card_list,i,card) + elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY + 1) then + table.insert(self.card_list, i, card) break end end @@ -251,183 +245,167 @@ function M:__OnDragEnd(context) isChangeCard = false self._area_handcard_list:AddChild(button) end - - end + end self:UpdateHandCardsPos() - if isChangeCard ==true then + if isChangeCard == true then self:SendChangeCard() end end end -function M:UpdateOutCardList(outcard,isShow,isMopai,seat) - if(isShow == nil) then - isShow = false +function M:UpdateOutCardList(outcard, isShow, isMopai, seat) + if (isShow == nil) then + isShow = false end - if(isMopai == nil) then - isMopai = false + if (isMopai == nil) then + isMopai = false end - self._area_outcard_list:RemoveChildren(0,-1,true) - local outcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") - - if outcard==0 then - outcards:GetChild("icon").icon ="ui://Main_RunBeard/202_1_300" + self._area_outcard_list:RemoveChildren(0, -1, true) + local outcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") + + if outcard == 0 then + outcards:GetChild("icon").icon = "ui://Main_RunBeard/202_1_300" else - outcards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/203_",outcard) + outcards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", outcard) end - outcards.x,outcards.y = 0,0 - local show_di_bg = outcards:GetChild("show_di_bg") + outcards.x, outcards.y = 0, 0 + local show_di_bg = outcards:GetChild("show_di_bg") --show_di_bg.visible = true - if(isShow)then - if outcard == 0 then - show_di_bg.visible = false - end - if(seat ~= nil and outcards~=nil)then - if(isMopai)then - if outcard ~= 0 then - outcards:GetTransition("mopai"..seat):Play(function( ) - -- show_di_bg.visible = true - - end) - end + if (isShow) then + if outcard == 0 then + show_di_bg.visible = false + end + if (seat ~= nil and outcards ~= nil) then + if (isMopai) then + if outcard ~= 0 then + outcards:GetTransition("mopai" .. seat):Play(function() + -- show_di_bg.visible = true + end) + end else - show_di_bg.visible = false - outcards:GetTransition("cpai"..seat):Play() + show_di_bg.visible = false + outcards:GetTransition("cpai" .. seat):Play() end - else - --show_di_bg.visible = true - end + else + --show_di_bg.visible = true + end else - show_di_bg.visible = false + show_di_bg.visible = false end self._area_outcard_list:AddChild(outcards) end --弃牌 -function M:UpdateQiPai( qi_list,isplay) - self._area_qipai_list:RemoveChildren(0,-1,true) - for i=1,#qi_list do - local qicards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") - qicards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/202_",qi_list[i]) - if(isplay)then - if(i == #qi_list) then - qicards:GetTransition("t0"):Play() +function M:UpdateQiPai(qi_list, isplay) + self._area_qipai_list:RemoveChildren(0, -1, true) + for i = 1, #qi_list do + local qicards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") + qicards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/202_", qi_list[i]) + if (isplay) then + if (i == #qi_list) then + qicards:GetTransition("t0"):Play() end - end - self._area_qipai_list:AddChild(qicards) - end + end + self._area_qipai_list:AddChild(qicards) + end end --摸牌动画 -function M:PlayingOutCardAnima( card) +function M:PlayingOutCardAnima(card) coroutine.start(function() - coroutine.wait(0.1) + coroutine.wait(0.1) self:ClearOutCard() end) end -function M:UpdateFzList( fz_list ,ispaly) +function M:UpdateFzList(fz_list, ispaly) printlog("jefe self UpdateFzList 2=======") - self._area_fz_list:RemoveChildren(0,-1,true) + self._area_fz_list:RemoveChildren(0, -1, true) - printlog("jefe self false UpdateFzList =======") - for i = 1,#fz_list do - local fzitem=nil + printlog("jefe self false UpdateFzList =======") + for i = 1, #fz_list do + local fzitem = nil if fz_list[i].type ~= RB_FZType.Kan then - fzitem =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") - if(ispaly == false)then - fzitem:RemoveChildren(0,-1,true) + fzitem = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") + if (ispaly == false) then + fzitem:RemoveChildren(0, -1, true) end end printlog("jefe self false RB_FZType UpdateFzList =======") if fz_list[i].type == RB_FZType.Chi or fz_list[i].type == RB_FZType.Bi then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetChild("card_"..1).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].active_card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetChild("card_" .. 1).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].active_card) fzcards:GetController("c2").selectedIndex = 1 - fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[1]) - fzcards:GetChild("card_"..3).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[2]) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 2).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[1]) + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[2]) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Peng then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Wei then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetController("c1").selectedIndex=1 - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetController("c1").selectedIndex = 1 + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.ChouWei then - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,2 do - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 2 do + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end - fzcards:GetChild("card_"..3).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Pao then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Ti then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - if j==4 then - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + if j == 4 then + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) else - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) end end - - end - -function M:playAnim( fzitem,fzcards, size,i,ispaly ) - if(ispaly == nil)then - ispaly =false - end - printlog("jefe self playAnim 2=======") - if(ispaly and i == size)then - local faArray= fzitem:GetChild("chiwei") - if(faArray~=nil)then - faArray:AddChild(fzcards) - else - fzitem:AddChild(fzcards) - end - else - fzitem:AddChild(fzcards) - end - self._area_fz_list:AddChild(fzitem) +function M:playAnim(fzitem, fzcards, size, i, ispaly) + if (ispaly == nil) then + ispaly = false + end + printlog("jefe self playAnim 2=======") + if (ispaly and i == size) then + local faArray = fzitem:GetChild("chiwei") + if (faArray ~= nil) then + faArray:AddChild(fzcards) + else + fzitem:AddChild(fzcards) + end + else + fzitem:AddChild(fzcards) + end + self._area_fz_list:AddChild(fzitem) end - - --出牌提示动画 - function M:ChuPaiTiShi() - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then +--出牌提示动画 +function M:ChuPaiTiShi() + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local chu_player = DataManager.CurrenRoom.self_player @@ -438,32 +416,31 @@ end selfplayeTable.paoCount = chu_player.paoCount selfplayeTable.hu_xi = chu_player.hu_xi local player = membe_deep_clone(selfplayeTable) - local mark_ting= {} - for i=1,#DataManager.CurrenRoom.self_player.handcard_list do - local card = DataManager.CurrenRoom.self_player.handcard_list[i] + local mark_ting = {} + for i = 1, #DataManager.CurrenRoom.self_player.handcard_list do + local card = DataManager.CurrenRoom.self_player.handcard_list[i] list_remove(player.handcard_list, card) local _player = membe_deep_clone(player) - local tingList = CardCheck.tingPai(_player,DataManager.CurrenRoom) + local tingList = CardCheck.tingPai(_player, DataManager.CurrenRoom) local isKan = false - for j=1,#player.fz_list do + for j = 1, #player.fz_list do if card == player.fz_list[j].card and player.fz_list[j].type == RB_FZType.Kan then - isKan =true + isKan = true end end if #tingList > 0 and isKan == false then - - mark_ting[#mark_ting+1] = card + mark_ting[#mark_ting + 1] = card end table.insert(player.handcard_list, card) - table.sort( player.handcard_list, ViewUtil.HandCardSort) + table.sort(player.handcard_list, ViewUtil.HandCardSort) end - -- print("ChuPaiTiShi",#mark_ting,vardump(player)) - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then - self._view :GetController("chupai").selectedIndex =1 - if #mark_ting>0 then - for i=1,#mark_ting do - for k=1,#self.card_list do - local card_view= self.card_list[k] + -- -- print("ChuPaiTiShi",#mark_ting,vardump(player)) + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + self._view:GetController("chupai").selectedIndex = 1 + if #mark_ting > 0 then + for i = 1, #mark_ting do + for k = 1, #self.card_list do + local card_view = self.card_list[k] if card_view.card_item == mark_ting[i] then card_view.btn_card:GetController("mark_ting").selectedIndex = 1 end @@ -471,13 +448,12 @@ end end end else - self._view :GetController("chupai").selectedIndex =0 - for k=1,#self.card_list do - local card_view= self.card_list[k] + self._view:GetController("chupai").selectedIndex = 0 + for k = 1, #self.card_list do + local card_view = self.card_list[k] card_view.btn_card:GetController("mark_ting").selectedIndex = 0 - end end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXGameController.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXGameController.lua index 4e3bfa11..4924c315 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXGameController.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXGameController.lua @@ -5,15 +5,15 @@ local M = {} --- Create a new HZ_GameController function M.new() - setmetatable(M,{__index = GameController}) - local self = setmetatable({}, {__index = M}) - self:init("汉寿跑胡子") - self.class = "RB_GameController" - return self + setmetatable(M, { __index = GameController }) + local self = setmetatable({}, { __index = M }) + self:init("汉寿跑胡子") + self.class = "RB_GameController" + return self end function M:init(name) - GameController.init(self,name) + GameController.init(self, name) self._eventmap[RB_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards self._eventmap[RB_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn @@ -31,79 +31,74 @@ function M:init(name) self._eventmap[RB_Protocol.GAME_EVT_RESULT1] = self.OneventResult1 self._eventmap[RB_Protocol.GAME_EVT_QIPAI] = self.OnEventQIPAI self._eventmap[RB_Protocol.GAME_EVT_ADD_CARD] = self.OnAddCard - - self._eventmap[RB_Protocol.GAME_EVT_Piao_Tip] = self.OnPiaoTip - self._eventmap[RB_Protocol.GAME_EVT_Piao_Action] = self.OnPiaoAction - self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai - self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim - -end + self._eventmap[RB_Protocol.GAME_EVT_Piao_Tip] = self.OnPiaoTip + self._eventmap[RB_Protocol.GAME_EVT_Piao_Action] = self.OnPiaoAction + self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai + self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim +end function M:SendXiPaiAction(callBack) local _data = {} - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_XIPAI, _data) - self.XiPaiCallBack=callBack + self.XiPaiCallBack = callBack end function M:OnEventXiPai(evt_data) - if evt_data["result"]==0 then - if self.XiPaiCallBack then - self.XiPaiCallBack() - end - else - ViewUtil.ErrorTip(1000000,"申请洗牌失败") - end - + if evt_data["result"] == 0 then + if self.XiPaiCallBack then + self.XiPaiCallBack() + end + else + ViewUtil.ErrorTip(1000000, "申请洗牌失败") + end end - function M:OnEventXiPaiAnim(evt_data) - printlog("洗牌动画===》》》》") - pt(evt_data) - local playeridList = evt_data["list"] - local my_isXiPai=false - local other_isXiPai=false - if playeridList and #playeridList>0 then - for i=1,#playeridList do - local p = self._room:GetPlayerById(playeridList[i]) - if p== self._room.self_player then - my_isXiPai=true - else - other_isXiPai=true - end - end - end - - self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventXiPai,my_isXiPai,other_isXiPai) - end) -end + printlog("洗牌动画===》》》》") + pt(evt_data) + local playeridList = evt_data["list"] + local my_isXiPai = false + local other_isXiPai = false + if playeridList and #playeridList > 0 then + for i = 1, #playeridList do + local p = self._room:GetPlayerById(playeridList[i]) + if p == self._room.self_player then + my_isXiPai = true + else + other_isXiPai = true + end + end + end + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.EventXiPai, my_isXiPai, other_isXiPai) + end) +end -- 发送出牌指令到服务器 function M:SendOutCard(card) local _data = {} _data["card"] = card local _room = self._room - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then _client:send(RB_Protocol.GAME_DIS_CARD, _data) end - end + --GAME_CHANGE_CARD GAME_DIS_CARD -function M:SendChangeCards( card_list ) +function M:SendChangeCards(card_list) local _data = {} if card_list then - _data["card_list"] = card_list - else - _data["card_list"]={} - end - local _client = ControllerManager.GameNetClinet + _data["card_list"] = card_list + else + _data["card_list"] = {} + end + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) + _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) end end @@ -111,43 +106,40 @@ function M:SendChangeTypeFace(TypeFace) -- body local _data = {} _data["typeface"] = TypeFace - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) + _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) end end - -function M:ConformToNextGame( ) - local _client = ControllerManager.GameNetClinet +function M:ConformToNextGame() + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_EVT_CHUI) + _client:send(RB_Protocol.GAME_EVT_CHUI) end end -- 发送放子选择到服务器 -function M:SendAction(id,num) +function M:SendAction(id, num) local _data = {} _data["id"] = id - if num ~=nil then + if num ~= nil then _data["biid"] = num end local _client = ControllerManager.GameNetClinet - if _client ~= nil then - _client:send(RB_Protocol.GAME_ACTION, _data) + if _client ~= nil then + _client:send(RB_Protocol.GAME_ACTION, _data) end end - -function M:SendPiao(piao,callBack) +function M:SendPiao(piao, callBack) local _data = {} _data["id"] = piao local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_EVT_Send_Piao, _data) - self.PiaoTipsCallBack=callBack + self.PiaoTipsCallBack = callBack end - function M:OnPiaoTip(evt_data) if ViewManager.GetCurrenView().dview_class == LobbyView then self:ReturnToRoom() @@ -158,8 +150,8 @@ function M:OnPiaoTip(evt_data) local reload = evt_data["reload"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoTips, piao,reload) - ControllerManager.IsSendCard=true + DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoTips, piao, reload) + ControllerManager.IsSendCard = true end ) end @@ -167,51 +159,50 @@ end function M:OnPiaoAction(evt_data) local seat = evt_data["seat"] local piao = evt_data["piao"] - if seat==DataManager.CurrenRoom.self_player.seat then - if self.PiaoTipsCallBack then - self.PiaoTipsCallBack() - self.PiaoTipsCallBack=nil - end - end + if seat == DataManager.CurrenRoom.self_player.seat then + if self.PiaoTipsCallBack then + self.PiaoTipsCallBack() + self.PiaoTipsCallBack = nil + end + end self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoAction, seat,piao) + DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoAction, seat, piao) end ) end - function M:OnEventSendCards(evt_data) - printlog("发牌事件===》》》") - pt(evt_data) + printlog("发牌事件===》》》") + pt(evt_data) if ViewManager.GetCurrenView().dview_class == LobbyView then self:ReturnToRoom() return end - - local _room = self._room - _room.self_player.currentNotPutCardList={} + + local _room = self._room + _room.self_player.currentNotPutCardList = {} _room.curren_round = _room.curren_round + 1 if _room.curren_round > 0 then _room.playing = true end - - local handcards = {} - if evt_data.card_list and #evt_data.card_list>0 then - handcards = evt_data["card_list"] - else - ViewUtil.ErrorTip(100000,"发牌数据异常") - end - + + local handcards = {} + if evt_data.card_list and #evt_data.card_list > 0 then + handcards = evt_data["card_list"] + else + ViewUtil.ErrorTip(100000, "发牌数据异常") + end + local p = _room.self_player - local seat =nil - if evt_data.bank_seat then - seat = evt_data["bank_seat"] - else - ViewUtil.ErrorTip(100001,"发牌座位异常") - end - + local seat = nil + if evt_data.bank_seat then + seat = evt_data["bank_seat"] + else + ViewUtil.ErrorTip(100001, "发牌座位异常") + end + _room.banker_seat = seat - for i=1,#_room.player_list do - _room.self_player.handcard_list ={} + for i = 1, #_room.player_list do + _room.self_player.handcard_list = {} _room.self_player.card_list = {} _room.player_list[i].hand_left_count = 20 _room.player_list[i].fz_list = {} @@ -220,12 +211,12 @@ function M:OnEventSendCards(evt_data) _room.player_list[i].hu_xi = 0 end self._cacheEvent:Enqueue(function() - _room.self_player.handcard_list=handcards + _room.self_player.handcard_list = handcards self._room.self_player.hand_left_count = #handcards - DispatchEvent(self._dispatcher,RB_GameEvent.SendCards, p) - --print("发牌结束=====打开标志") - ControllerManager.IsSendCard=true - end) + DispatchEvent(self._dispatcher, RB_GameEvent.SendCards, p) + ---- print("发牌结束=====打开标志") + ControllerManager.IsSendCard = true + end) end function M:OnEventOutCard(evt_data) @@ -233,13 +224,13 @@ function M:OnEventOutCard(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(seat == _room.self_player.seat) then - list_remove(_room.self_player.handcard_list,card) + local _room = self._room + if (seat == _room.self_player.seat) then + list_remove(_room.self_player.handcard_list, card) end p.DiceCard = card - p.hand_left_count = p.hand_left_count -1 - DispatchEvent(self._dispatcher,RB_GameEvent.OutCard, p,card) + p.hand_left_count = p.hand_left_count - 1 + DispatchEvent(self._dispatcher, RB_GameEvent.OutCard, p, card) end) end @@ -248,10 +239,10 @@ function M:OnEventQIPAI(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(not p.outcard_list) then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card - DispatchEvent(self._dispatcher,RB_GameEvent.QiCard, seat,card) + local _room = self._room + if (not p.outcard_list) then p.outcard_list = {} end + p.outcard_list[#p.outcard_list + 1] = card + DispatchEvent(self._dispatcher, RB_GameEvent.QiCard, seat, card) end) end @@ -262,10 +253,10 @@ function M:OnEventTakeCard(evt_data) local left_count = evt_data["left_count"] local p = _room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - if card ~=0 then + if card ~= 0 then p.DiceCard = card end - DispatchEvent(self._dispatcher,RB_GameEvent.GetCard, seat, card, left_count) + DispatchEvent(self._dispatcher, RB_GameEvent.GetCard, seat, card, left_count) end) end @@ -274,67 +265,64 @@ function M:OnAddCard(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] local p = _room:GetPlayerBySeat(seat) - + self._cacheEvent:Enqueue(function() p.DiceCard = 0 - p.hand_left_count = p.hand_left_count +1 + p.hand_left_count = p.hand_left_count + 1 if (seat == _room.self_player.seat) then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - DispatchEvent(self._dispatcher,RB_GameEvent.AddCard, seat, card) + DispatchEvent(self._dispatcher, RB_GameEvent.AddCard, seat, card) end) end function M:OnEventOutHint(evt_data) - printlog("出牌提示事件===》》》") - pt(evt_data) - self._cacheEvent:Enqueue(function() - - DispatchEvent(self._dispatcher,RB_GameEvent.OutHint) + printlog("出牌提示事件===》》》") + pt(evt_data) + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.OutHint) end) - end function M:OnEventTurn(evt_data) local seat = evt_data["seat"] self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventTurn, seat) + DispatchEvent(self._dispatcher, RB_GameEvent.EventTurn, seat) end) end function M:OnEventFzTips(evt_data) - printlog("放子提示事件===》》》") - pt(evt_data) + printlog("放子提示事件===》》》") + pt(evt_data) self._cacheEvent:Enqueue(function() local tiplist = FZTipList.new() - local list = evt_data["tip_list"] - local uid = evt_data["uid"] - for i=1,#list do - local dtip = list[i] - local tip = {} - tip.id = dtip["id"] - tip.weight = dtip["weight"] - tip.card = dtip["card"] - tip.type = dtip["type"] - tip.bi_list = dtip["bi_list"] - if (dtip["opcard"]) then - local opcard = dtip["opcard"] - tip.OpCard = opcard - table.sort(tip.OpCard) - tip.OpCard[3] = tip.Card - end - tiplist:AddTip(tip) - + local list = evt_data["tip_list"] + local uid = evt_data["uid"] + for i = 1, #list do + local dtip = list[i] + local tip = {} + tip.id = dtip["id"] + tip.weight = dtip["weight"] + tip.card = dtip["card"] + tip.type = dtip["type"] + tip.bi_list = dtip["bi_list"] + if (dtip["opcard"]) then + local opcard = dtip["opcard"] + tip.OpCard = opcard + table.sort(tip.OpCard) + tip.OpCard[3] = tip.Card end - DispatchEvent(self._dispatcher,RB_GameEvent.FZTips, tiplist,uid) + tiplist:AddTip(tip) + end + DispatchEvent(self._dispatcher, RB_GameEvent.FZTips, tiplist, uid) end) end function M:OnEventFzAction(evt_data) - printlog("放子行为提示事件===》》》") - pt(evt_data) + printlog("放子行为提示事件===》》》") + pt(evt_data) local _room = self._room - _room.self_player.currentNotPutCardList=evt_data["notput"] + _room.self_player.currentNotPutCardList = evt_data["notput"] local playerid = evt_data["playerid"] local card = evt_data["card"] local actice_card = evt_data["active_card"] @@ -344,181 +332,173 @@ function M:OnEventFzAction(evt_data) local huxi = evt_data["hu_xi"] local p = _room:GetPlayerById(playerid) self._cacheEvent:Enqueue(function() - local isNeedDelHandCard =0 - p.hu_xi = huxi - local fz = {} - fz.card = card - fz.type = ftype - fz.active_card = actice_card - fz.from_seat = from_seat - fz.opcard =opcard - local remove_num = #opcard - if ftype == RB_FZType.Chi then - p.fz_list[#p.fz_list+1] = fz + local isNeedDelHandCard = 0 + p.hu_xi = huxi + local fz = {} + fz.card = card + fz.type = ftype + fz.active_card = actice_card + fz.from_seat = from_seat + fz.opcard = opcard + local remove_num = #opcard + if ftype == RB_FZType.Chi then + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Bi then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - list_remove(_room.self_player.handcard_list,fz.card) + list_remove(_room.self_player.handcard_list, fz.card) end elseif ftype == RB_FZType.Peng then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Kan then if (p == _room.self_player) then - if #opcard==2 then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + if #opcard == 2 then + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz end elseif ftype == RB_FZType.ChouWei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,2 do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, 2 do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Wei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Pao then - - if (p == _room.self_player) then - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) - end - end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Pao - end - end - local num =0 - for i=1,#_room.self_player.handcard_list do - if card == _room.self_player.handcard_list[i] then - num=num+1 - end - end - if num>0 then - isNeedDelHandCard =num - - for i=1,num do - list_remove(_room.self_player.handcard_list,card) - end - local isAddTi =false - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - isAddTi=true - remove_num= 0 - end - end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz - end - end - - else - local num =0 - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - num=1 - remove_num= 0 - end - end - if num==0 then - p.fz_list[#p.fz_list+1] = fz - end - end - - elseif ftype == RB_FZType.Ti then - if (p == _room.self_player) then - for i=1,#p.fz_list do + for i = 1, #p.fz_list do if p.fz_list[i].card == card then if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Ti + remove_num = 0 + p.fz_list[i].type = RB_FZType.Pao end end - local num =0 - for i=1,#_room.self_player.handcard_list do + local num = 0 + for i = 1, #_room.self_player.handcard_list do if card == _room.self_player.handcard_list[i] then - num=num+1 + num = num + 1 end end - if num>0 then - isNeedDelHandCard =num + if num > 0 then + isNeedDelHandCard = num - for i=1,num do - list_remove(_room.self_player.handcard_list,card) + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) end - local isAddTi =false - for i=1,#p.fz_list do + local isAddTi = false + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - isAddTi=true + p.fz_list[i].type = RB_FZType.Pao + isAddTi = true + remove_num = 0 end end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz end end - else - local num =0 - for i=1,#p.fz_list do + local num = 0 + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - num=1 + p.fz_list[i].type = RB_FZType.Pao + num = 1 + remove_num = 0 end end - if num==0 then - p.fz_list[#p.fz_list+1] = fz + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz end + end + elseif ftype == RB_FZType.Ti then + if (p == _room.self_player) then + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + if p.fz_list[i].type == RB_FZType.Kan then + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) + end + end + remove_num = 0 + p.fz_list[i].type = RB_FZType.Ti + end + end + local num = 0 + for i = 1, #_room.self_player.handcard_list do + if card == _room.self_player.handcard_list[i] then + num = num + 1 + end + end + if num > 0 then + isNeedDelHandCard = num - end - + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) + end + local isAddTi = false + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + isAddTi = true + end + end + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz + end + end + else + local num = 0 + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + num = 1 + end + end + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz + end + end end - - + + p.hand_left_count = p.hand_left_count - remove_num --[[if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then coroutine.start(function() coroutine.wait(0.5) DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) - end) - else - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) + end) + else + DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) end--]] - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) - + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) end) end @@ -526,18 +506,18 @@ function M:OnEventHu(evt_data) local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) - -- print(win_p.hand_left_count) - + -- -- print(win_p.hand_left_count) + self._cacheEvent:Enqueue(function() win_p.card_list = cards - table.sort( win_p.card_list, ViewUtil.HandCardSort) - DispatchEvent(self._dispatcher,RB_GameEvent.ZPHuCard, evt_data["seat"],evt_data["from_seat"],cards) + table.sort(win_p.card_list, ViewUtil.HandCardSort) + DispatchEvent(self._dispatcher, RB_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards) end) end function M:OneventResult1(evt_data) - printlog("结算=============>>>") - pt(evt_data) + printlog("结算=============>>>") + pt(evt_data) local over = evt_data.type --0:小结算 1:小大结算 2:大结算 self._room.playing = false @@ -549,17 +529,17 @@ function M:OneventResult1(evt_data) p.outcard_list = {} end self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult1, result); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult1, result); end) elseif 1 == over or 2 == over then DataManager.CurrenRoom.Over = true - ControllerManager.SetGameNetClient(nil,true) + ControllerManager.SetGameNetClient(nil, true) local total_result = evt_data.total_result local result = evt_data.result self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult2, result, total_result, over); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult2, result, total_result, over); end) end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXMainView.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXMainView.lua index 6915bd49..1c1cfd58 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXMainView.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXMainView.lua @@ -22,8 +22,8 @@ local Fix_Msg_Chat = { --- Create a new ZZ_MainView function M.new() - setmetatable(M, {__index = ZPMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = ZPMainView }) + local self = setmetatable({}, { __index = M }) self.class = 'RunBeard_MainView' self._full = true self:init() @@ -37,6 +37,7 @@ function M:getCardItem(card_1, card_2) return card_1 .. '2_' .. card_2 end end + function M:InitView(url) local _room = self._room self.Fix_Msg_Chat = Fix_Msg_Chat @@ -48,9 +49,9 @@ function M:InitView(url) SettingView.onEXMainCallback = handler(self, self.UpdateCardDisplay) SettingView.onUpdataCardSizeCallback = handler(self, self.UpdateCardSize) - if DataManager.CurrenRoom.change_card_display==nil then - self:UpdateCardDisplay(2) - end + if DataManager.CurrenRoom.change_card_display == nil then + self:UpdateCardDisplay(2) + end for i = 1, #_room.player_list do local p = _room.player_list[i] local head = self._player_info[self:GetPos(p.seat)] @@ -123,120 +124,116 @@ function M:setBtn() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end - function M:NewPlayerCardInfoView(view, index) if index == 1 then return PlayerSelfCardInfoView.new(view, self) end return PlayerCardInfoView.new(view, self) end + function M:closeTipOnTuoguan() if self._clearingView ~= nil then self._clearingView:Close() end self:__CloseTip() end + function M:EventInit() MainView.EventInit(self) local _room = self._room local _view = self._view local _player_info = self._player_info local _gamectr = self._gamectr - - _gamectr:AddEventListener(GameEvent.EventXiPai,function( ... ) - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] - self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - - end - - - if ( currentPlayer2 ) then - --self._popEvent = false - local xipaiCB2=function () - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end - - - end) - _gamectr:AddEventListener(GameEvent.OnPiaoTips, function(...) - local arg = {...} + _gamectr:AddEventListener(GameEvent.EventXiPai, function(...) + local arg = { ... } + local currentPlayer1 = arg[1] + local currentPlayer2 = arg[2] + self._popEvent = false + if (currentPlayer1) then + local xipaiCB = function() + self._popEvent = true + end + self:PlayXiPai(xipaiCB) + end + + + if (currentPlayer2) then + --self._popEvent = false + local xipaiCB2 = function() + self._popEvent = true + end + self:PlayXiPai1(xipaiCB2) + end + end) + + _gamectr:AddEventListener(GameEvent.OnPiaoTips, function(...) + local arg = { ... } local piao = arg[1] local reload = arg[2] - if reload==0 then - --self._popEvent = false - self._leftcard = 1 - self._leftcard = 1 - local rightpanel = self._view:GetChild('right_panel') - local tex_round = rightpanel:GetChild('tex_round') - if tex_round ~= nil then - tex_round.text = '第 ' .. _room.curren_round .. ' 局' - end - self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. '/' .. _room.room_config.round .. ' 局' + if reload == 0 then + --self._popEvent = false + self._leftcard = 1 + self._leftcard = 1 + local rightpanel = self._view:GetChild('right_panel') + local tex_round = rightpanel:GetChild('tex_round') + if tex_round ~= nil then + tex_round.text = '第 ' .. _room.curren_round .. ' 局' + end + self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. '/' .. _room.room_config.round .. ' 局' - self._state.selectedIndex = 1 - self:closeTipOnTuoguan() - local list = _room.player_list - for i = 1, #list do - local p = list[i] - p.hu_xi = 0 - local _info = self._player_card_info[self:GetPos(p.seat)] - _info:SetPlayer(p) - local info = self._player_info[self:GetPos(p.seat)] - info:FillData(p) - info:MarkBank(p.seat == _room.banker_seat) - info:Ready(false) - info:UpdatePiao(-1) - info._view:GetController('huxi').selectedIndex = 1 - info._view:GetChild('huxi').text = p.hu_xi - info._view:GetController('zhanji').selectedIndex = 0 + self._state.selectedIndex = 1 + self:closeTipOnTuoguan() + local list = _room.player_list + for i = 1, #list do + local p = list[i] + p.hu_xi = 0 + local _info = self._player_card_info[self:GetPos(p.seat)] + _info:SetPlayer(p) + local info = self._player_info[self:GetPos(p.seat)] + info:FillData(p) + info:MarkBank(p.seat == _room.banker_seat) + info:Ready(false) + info:UpdatePiao(-1) + info._view:GetController('huxi').selectedIndex = 1 + info._view:GetChild('huxi').text = p.hu_xi + info._view:GetController('zhanji').selectedIndex = 0 + + if _room.hpOnOff == 1 or _room:checkHpNonnegative() then + if p.total_hp == nil then + p.total_hp = 0 + end + info._view:GetController('zhanji').selectedIndex = 1 + info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) + end + end + end + --local card_info = self._player_card_info[1] + --card_info:UpdateIsOnClick(false) + --card_info:InitHandCard(true) + printlog("飘分提示==>>>") + + self._player_card_info[1]:ShowPiao(piao) + end) - if _room.hpOnOff == 1 or _room:checkHpNonnegative() then - if p.total_hp == nil then - p.total_hp = 0 - end - info._view:GetController('zhanji').selectedIndex = 1 - info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) - end - end - - end - --local card_info = self._player_card_info[1] - --card_info:UpdateIsOnClick(false) - --card_info:InitHandCard(true) - printlog("飘分提示==>>>") - - self._player_card_info[1]:ShowPiao(piao) - end) - _gamectr:AddEventListener(GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] head_info:UpdatePiao(piao) end) - + _gamectr:AddEventListener( GameEvent.SendCards, function(...) @@ -283,7 +280,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.GetCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] local _leftcard = arg[3] @@ -309,7 +306,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.AddCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] self._popEvent = false @@ -330,7 +327,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.EventTurn, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local list = _room.player_list local readyNum = 0 @@ -362,7 +359,7 @@ function M:EventInit() function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -399,7 +396,7 @@ function M:EventInit() self:__CloseTip() self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] local p = _room:GetPlayerBySeat(seat) @@ -413,7 +410,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local _uid = arg[2] self:__FangziTip(_tip, _uid) @@ -428,7 +425,7 @@ function M:EventInit() self._left_time = 0 self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local w = arg[1] local l = arg[2] local cards = arg[3] @@ -464,7 +461,7 @@ function M:EventInit() function(...) self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -543,7 +540,7 @@ function M:EventInit() GameEvent.ZPResult2, function(...) self._left_time = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -574,8 +571,8 @@ end function M:ChangeCards(list) local _gamectr = ControllerManager.GetController(GameController) if _gamectr then - _gamectr:SendChangeCards(list) - end + _gamectr:SendChangeCards(list) + end end function M:__FangziTip(tip, _uid) @@ -599,12 +596,12 @@ function M:__FangziTip(tip, _uid) local td = tip.tip_map_type[_tlist[k]][1] local url = 'ui://Main_RunBeard/Btn_fztip' local btn_t = _lit_fanzi:AddItemFromPool(url) - if td.type==8 then - btn_t:GetChild("hupai").icon="ui://Main_RunBeard/201_1_" .. td.card - btn_t:GetController("hupai").selectedIndex=1 - end + if td.type == 8 then + btn_t:GetChild("hupai").icon = "ui://Main_RunBeard/201_1_" .. td.card + btn_t:GetController("hupai").selectedIndex = 1 + end btn_t.icon = 'ui://Main_RunBeard/newop_' .. td.type - btn_t.data = {tip, td, tip_hu} + btn_t.data = { tip, td, tip_hu } btn_t.onClick:Set(self.__TipAction, self) end if p.hand_left_count ~= 0 then @@ -637,6 +634,7 @@ function M:__FangziTip(tip, _uid) _chipeng_tip.x = _chipeng_tip.x + 200 _chipeng_tip.y = _chipeng_tip.y - 50 end + function M:__TipAction(context) local data = context.sender.data local _gamectr = self._gamectr @@ -825,13 +823,13 @@ function M:deepcopy(object) end function M:OnFangziAction(...) - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] local num = arg[3] --if fz.type == RB_FZType.Peng or fz.type == RB_FZType.Chi or fz.type == RB_FZType.Bi then - self:__CloseTip() + self:__CloseTip() --end if (player == self._room.self_player) then local info = _player_card_info[self:GetPos(player.seat)] @@ -918,7 +916,7 @@ function M:OnFangziAction(...) elseif fz.type == RB_FZType.Ti then self:PlaySound(player.self_user.sex, 'F_SaoChuan') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'ti') - -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti") + -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti") end effect.touchable = false effect.x, effect.y = 0, 0 @@ -950,15 +948,15 @@ function M:OnFangziAction(...) for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] - --print(p.hu_xi) + ---- print(p.hu_xi) info._view:GetChild('huxi').text = p.hu_xi end - - if player == self._room.self_player then - local info = _player_card_info[self:GetPos(player.seat)] - info:SetNotPutCard() - end - + + if player == self._room.self_player then + local info = _player_card_info[self:GetPos(player.seat)] + info:SetNotPutCard() + end + self._popEvent = true coroutine.start( function() @@ -993,13 +991,13 @@ function M:ReloadRoom() else self._player_info[self:GetPos(p.seat)]:Ready(false) end - - --if p.piao then - -- self._player_info[self:GetPos(p.seat)]:UpdatePiao(-1) - --else - self._player_info[self:GetPos(p.seat)]:UpdatePiao(p.piao) - --end - + + --if p.piao then + -- self._player_info[self:GetPos(p.seat)]:UpdatePiao(-1) + --else + self._player_info[self:GetPos(p.seat)]:UpdatePiao(p.piao) + --end + if self._state.selectedIndex == 1 then local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('huxi').selectedIndex = 1 @@ -1028,8 +1026,8 @@ function M:ReloadRoom() card_info:ChuPaiTiShi() if self._room.self_player.card_list ~= nil and - #self._room.self_player.handcard_list == #self._room.self_player.card_list - then + #self._room.self_player.handcard_list == #self._room.self_player.card_list + then local _list = self:deepcopy(self._room.self_player.card_list) local cards = {} for i = 1, #_list do diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXPlayBackView.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXPlayBackView.lua index 4371e666..cec497bc 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXPlayBackView.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/EXPlayBackView.lua @@ -21,8 +21,8 @@ end --- Create a new function M.new() - setmetatable(M, {__index = PlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'PlayBackView' self:init() @@ -185,7 +185,7 @@ function M:ShowStep(index) self._room.self_player.handcard_list = p.card_list info:InitHandCard(false) end - + --[[if step.cmd == Record_Event.Evt_ChangePaiXing then local _card_list = {} for i = 1, #step.card_list do @@ -202,7 +202,7 @@ function M:ShowStep(index) info:UpdateHandCards(step.card_list) end end--]] - + if step.cmd == Record_Event.Evt_OutCard or step.cmd == Record_Event.Evt_GetCard then if step.DiceCard ~= nil and step.DiceCard ~= 0 then if p.seat == step.seat then @@ -220,7 +220,7 @@ function M:ShowStep(index) info:UpdateQiPai(p.outcard_list) end end - -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) + -- -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) if step.cmd == Record_Event.Evt_result then --[[local _room = DataManager.CurrenRoom local result = step.result @@ -325,6 +325,7 @@ function M:CmdGetCard(cmd, index) data.seat = cmd.seat data.DiceCard = cmd.data.card end + function M:CmdThrowCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -334,6 +335,7 @@ function M:CmdThrowCard(cmd, index) data.out_card_list = cmd.data.card u.outcard_list[#u.outcard_list + 1] = cmd.data.card end + function M:CmdAddCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/PlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/PlayerSelfCardInfoView.lua index 22462dbb..6d02a506 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/PlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi/PlayerSelfCardInfoView.lua @@ -1,10 +1,10 @@ local PlayerSelfCardInfoView = import(".main.ZPPlayerSelfCardInfoView") local CardCheck = import(".main.CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(M, {__index = PlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(M, { __index = PlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -13,52 +13,50 @@ function M.new(view,mainView) return self end - function M:onTouchBegin(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local button = context.sender local card = button.data - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self:ShowHuTip(card.card_item) end - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", card.card_item) card.btn_card.sortingOrder = 100 - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - card.btn_card.xy = Vector2.New(card.btn_card.x+20 ,card.btn_card.y-50) + local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50) card.touch_pos = xy - button.xy - end function M:ClearMpList(mpList) - local tempList={} - for k,v in pairs(mpList) do - if #v>0 then - table.insert(tempList,v) - end - end - - return tempList + local tempList = {} + for k, v in pairs(mpList) do + if #v > 0 then + table.insert(tempList, v) + end + end + + return tempList end function M:__OnDragEnd(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end local button = context.sender - + local card = button.data - + local _room = DataManager.CurrenRoom card.btn_card.sortingOrder = 0 - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) - local currentCtrS=IsHasDictionary(card.card_item,DataManager.CurrenRoom.self_player.currentNotPutCardList) - if currentCtrS==nil then currentCtrS=false end - if (button.y < -380 and _room.curren_outcard_seat == _room.self_player.seat) and currentCtrS==false then + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + local currentCtrS = IsHasDictionary(card.card_item, DataManager.CurrenRoom.self_player.currentNotPutCardList) + if currentCtrS == nil then currentCtrS = false end + if (button.y < -380 and _room.curren_outcard_seat == _room.self_player.seat) and currentCtrS == false then button.touchable = false self.outcard_button = card self:UpdateIsOnClick(false) @@ -66,7 +64,7 @@ function M:__OnDragEnd(context) else local isChangeCard = false self.outcard_button = nil - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_", card.card_item) self._area_handcard_list:AddChild(button) if #self.card_list == 1 then isChangeCard = false @@ -74,194 +72,189 @@ function M:__OnDragEnd(context) return end local CountCards = {} - for i=1,#self.card_list do + for i = 1, #self.card_list do local lists = {} if CountCards[self.card_list[i].index_X] == nil then - lists[#lists+1] = self.card_list[i] - CountCards[self.card_list[i].index_X]= lists + lists[#lists + 1] = self.card_list[i] + CountCards[self.card_list[i].index_X] = lists else - CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X]+1] =self.card_list[i] + CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X] + 1] = self.card_list[i] end end - - CountCards=self:ClearMpList(CountCards) - + + CountCards = self:ClearMpList(CountCards) + local minmark = 1 local maxmark = #self.card_list - if card == self.card_list[1] or card == self.card_list[#self.card_list] then + if card == self.card_list[1] or card == self.card_list[#self.card_list] then if self.card_list[1].index_X == self.card_list[2].index_X then - minmark =2 + minmark = 2 end - if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list-1].index_X then - maxmark =#self.card_list-1 + if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list - 1].index_X then + maxmark = #self.card_list - 1 end end - if button.x+button.width/2 < self.card_list[minmark].btn_card.x and #CountCards<12 then - list_remove(self.card_list,card) + if button.x + button.width / 2 < self.card_list[minmark].btn_card.x and #CountCards < 12 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X < card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X + 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X < card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X + 1 + end end else - for i=1,#self.card_list do - self.card_list[i].index_X = self.card_list[i].index_X + 1 + for i = 1, #self.card_list do + self.card_list[i].index_X = self.card_list[i].index_X + 1 end end - card.index_X =1 - card.index_Y =1 - table.insert(self.card_list,1,card) + card.index_X = 1 + card.index_Y = 1 + table.insert(self.card_list, 1, card) isChangeCard = true - elseif button.x+button.width/2 > (self.card_list[maxmark].btn_card.x +button.width) and #CountCards<12 then - list_remove(self.card_list,card) + elseif button.x + button.width / 2 > (self.card_list[maxmark].btn_card.x + button.width) and #CountCards < 12 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end end - card.index_X =self.card_list[#self.card_list].index_X+1 - card.index_Y =1 - self.card_list[#self.card_list+1] =card + card.index_X = self.card_list[#self.card_list].index_X + 1 + card.index_Y = 1 + self.card_list[#self.card_list + 1] = card isChangeCard = true - else + else local MoveCard = false local MoveCardPos = 0 local MoveCardY = 0 - for i=1,#CountCards do - if CountCards[i] then - local card_view = CountCards[i][1] - if card_view~=nil then - if button.x+button.width/2 > card_view.old_postion.x and button.x+button.width/2 < (card_view.old_postion.x+button.width) then - if card ~= card_view and #CountCards[i] <4 and card.index_X ~= card_view.index_X then - - MoveCardPos = i - MoveCardY = #CountCards[i]+1 - MoveCard = true - list_remove(self.card_list,card) - end - end - end - end - - end - local MoveCardindex = 0 - -- local MoveCardY = 0 - if button.x+button.width/2 > card.old_postion.x and button.x+button.width/2 < (card.old_postion.x+button.width) then - if #CountCards[card.index_X]>1 then - for i=1,#CountCards[card.index_X] do - local _cv = CountCards[card.index_X][i] - if _cv ~= card then - if button.y+button.height/2 > _cv.btn_card.y and button.y+button.height/2 < (_cv.btn_card.y+button.height) then - --向下移動 - if ((button.y+button.height/2) +20) > (card.old_postion.y+button.height) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - --向上移動 - elseif ((button.y+button.height/2) -20) < card.old_postion.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - end - elseif i == #CountCards[card.index_X] and button.y+button.height/2 < _cv.btn_card.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - elseif i == 1 and button.y+button.height/2 > (_cv.btn_card.y+button.width) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) + for i = 1, #CountCards do + if CountCards[i] then + local card_view = CountCards[i][1] + if card_view ~= nil then + if button.x + button.width / 2 > card_view.old_postion.x and button.x + button.width / 2 < (card_view.old_postion.x + button.width) then + if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then + MoveCardPos = i + MoveCardY = #CountCards[i] + 1 + MoveCard = true + list_remove(self.card_list, card) end end end end - end - if MoveCard ==true and MoveCardindex ==0 then + local MoveCardindex = 0 + -- local MoveCardY = 0 + if button.x + button.width / 2 > card.old_postion.x and button.x + button.width / 2 < (card.old_postion.x + button.width) then + if #CountCards[card.index_X] > 1 then + for i = 1, #CountCards[card.index_X] do + local _cv = CountCards[card.index_X][i] + if _cv ~= card then + if button.y + button.height / 2 > _cv.btn_card.y and button.y + button.height / 2 < (_cv.btn_card.y + button.height) then + --向下移動 + if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + --向上移動 + elseif ((button.y + button.height / 2) - 20) < card.old_postion.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + end + elseif i == #CountCards[card.index_X] and button.y + button.height / 2 < _cv.btn_card.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + elseif i == 1 and button.y + button.height / 2 > (_cv.btn_card.y + button.width) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + end + end + end + end + end + if MoveCard == true and MoveCardindex == 0 then local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end if MoveCardPos > card.index_X then - MoveCardPos = MoveCardPos-1 + MoveCardPos = MoveCardPos - 1 end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do if MoveCardPos == self.card_list[i].index_X then - table.insert(self.card_list,(i+1),card) + table.insert(self.card_list, (i + 1), card) break end end isChangeCard = true - --上下移动 - elseif MoveCard ==true and MoveCardindex ~= 0 then - for i=1,#self.card_list do - if card.index_X == self.card_list[i].index_X then + --上下移动 + elseif MoveCard == true and MoveCardindex ~= 0 then + for i = 1, #self.card_list do + if card.index_X == self.card_list[i].index_X then --向下移动 if MoveCardindex == -1 then - if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then + if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then self.card_list[i].index_Y = self.card_list[i].index_Y + 1 - end - --向上移动 + --向上移动 else - if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 - + if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do - if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY-1) then - table.insert(self.card_list,(i+1),card) + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do + if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY - 1) then + table.insert(self.card_list, (i + 1), card) break - elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY+1) then - table.insert(self.card_list,i,card) + elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY + 1) then + table.insert(self.card_list, i, card) break end end @@ -270,183 +263,169 @@ function M:__OnDragEnd(context) isChangeCard = false self._area_handcard_list:AddChild(button) end - - end + end self:UpdateHandCardsPos() - if isChangeCard ==true then + if isChangeCard == true then self:SendChangeCard() end end end -function M:UpdateOutCardList(outcard,isShow,isMopai,seat) - if(isShow == nil) then - isShow = false +function M:UpdateOutCardList(outcard, isShow, isMopai, seat) + if (isShow == nil) then + isShow = false end - if(isMopai == nil) then - isMopai = false + if (isMopai == nil) then + isMopai = false end - self._area_outcard_list:RemoveChildren(0,-1,true) - local outcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") - - if outcard==0 then - outcards:GetChild("icon").icon ="ui://Main_RunBeard/202_1_300" + self._area_outcard_list:RemoveChildren(0, -1, true) + local outcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") + + if outcard == 0 then + outcards:GetChild("icon").icon = "ui://Main_RunBeard/202_1_300" else - outcards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/203_",outcard) + outcards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", outcard) end - outcards.x,outcards.y = 0,0 - local show_di_bg = outcards:GetChild("show_di_bg") - -- show_di_bg.visible = true - if(isShow)then - if outcard == 0 then - show_di_bg.visible = false - end - if(seat ~= nil and outcards~=nil)then - if(isMopai)then - if outcard ~= 0 then - outcards:GetTransition("mopai"..seat):Play(function( ) - -- show_di_bg.visible = true - - end) - end + outcards.x, outcards.y = 0, 0 + local show_di_bg = outcards:GetChild("show_di_bg") + -- show_di_bg.visible = true + if (isShow) then + if outcard == 0 then + show_di_bg.visible = false + end + if (seat ~= nil and outcards ~= nil) then + if (isMopai) then + if outcard ~= 0 then + outcards:GetTransition("mopai" .. seat):Play(function() + -- show_di_bg.visible = true + end) + end else - show_di_bg.visible = false - outcards:GetTransition("cpai"..seat):Play() + show_di_bg.visible = false + outcards:GetTransition("cpai" .. seat):Play() end - else - --show_di_bg.visible = true - end + else + --show_di_bg.visible = true + end else - show_di_bg.visible = false + show_di_bg.visible = false end self._area_outcard_list:AddChild(outcards) end --弃牌 -function M:UpdateQiPai( qi_list,isplay) - self._area_qipai_list:RemoveChildren(0,-1,true) - for i=1,#qi_list do - local qicards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") - qicards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/202_",qi_list[i]) - if(isplay)then - if(i == #qi_list) then - qicards:GetTransition("t0"):Play() +function M:UpdateQiPai(qi_list, isplay) + self._area_qipai_list:RemoveChildren(0, -1, true) + for i = 1, #qi_list do + local qicards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") + qicards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/202_", qi_list[i]) + if (isplay) then + if (i == #qi_list) then + qicards:GetTransition("t0"):Play() end - end - self._area_qipai_list:AddChild(qicards) - end + end + self._area_qipai_list:AddChild(qicards) + end end --摸牌动画 -function M:PlayingOutCardAnima( card) +function M:PlayingOutCardAnima(card) coroutine.start(function() - coroutine.wait(0.1) + coroutine.wait(0.1) self:ClearOutCard() end) end -function M:UpdateFzList( fz_list ,ispaly) - self._area_fz_list:RemoveChildren(0,-1,true) - for i = 1,#fz_list do - local fzitem=nil +function M:UpdateFzList(fz_list, ispaly) + self._area_fz_list:RemoveChildren(0, -1, true) + for i = 1, #fz_list do + local fzitem = nil if fz_list[i].type ~= RB_FZType.Kan then - fzitem =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") - if(ispaly == false)then - fzitem:RemoveChildren(0,-1,true) + fzitem = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") + if (ispaly == false) then + fzitem:RemoveChildren(0, -1, true) end end if fz_list[i].type == RB_FZType.Chi or fz_list[i].type == RB_FZType.Bi then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetChild("card_"..1).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].active_card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetChild("card_" .. 1).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].active_card) fzcards:GetController("c2").selectedIndex = 1 - fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[1]) - fzcards:GetChild("card_"..3).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[2]) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 2).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[1]) + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[2]) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Peng then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Wei then - - --[[ local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + --[[ local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") fzcards:GetController("c1").selectedIndex=1 for j=1,3 do fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) end fzcards.x,fzcards.y = 0,0 self:playAnim(fzitem,fzcards,#fz_list,i,ispaly)--]] - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,2 do - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 2 do + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end - fzcards:GetChild("card_"..3).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.ChouWei then - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,2 do - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 2 do + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end - fzcards:GetChild("card_"..3).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Pao then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Ti then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - if j==4 then - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + if j == 4 then + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) else - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) end end end - -function M:playAnim( fzitem,fzcards, size,i,ispaly ) - if(ispaly == nil)then - ispaly =false - end - if(ispaly and i == size)then - local faArray= fzitem:GetChild("chiwei") - if(faArray~=nil)then - faArray:AddChild(fzcards) - else - fzitem:AddChild(fzcards) - end - else - fzitem:AddChild(fzcards) - end - self._area_fz_list:AddChild(fzitem) +function M:playAnim(fzitem, fzcards, size, i, ispaly) + if (ispaly == nil) then + ispaly = false + end + if (ispaly and i == size) then + local faArray = fzitem:GetChild("chiwei") + if (faArray ~= nil) then + faArray:AddChild(fzcards) + else + fzitem:AddChild(fzcards) + end + else + fzitem:AddChild(fzcards) + end + self._area_fz_list:AddChild(fzitem) end - - --出牌提示动画 - function M:ChuPaiTiShi() - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then +--出牌提示动画 +function M:ChuPaiTiShi() + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local chu_player = DataManager.CurrenRoom.self_player @@ -457,33 +436,32 @@ end selfplayeTable.paoCount = chu_player.paoCount selfplayeTable.hu_xi = chu_player.hu_xi local player = membe_deep_clone(selfplayeTable) - local mark_ting= {} - for i=1,#DataManager.CurrenRoom.self_player.handcard_list do - local card = DataManager.CurrenRoom.self_player.handcard_list[i] + local mark_ting = {} + for i = 1, #DataManager.CurrenRoom.self_player.handcard_list do + local card = DataManager.CurrenRoom.self_player.handcard_list[i] list_remove(player.handcard_list, card) local _player = membe_deep_clone(player) - local tingList = CardCheck.tingPai(_player,DataManager.CurrenRoom) + local tingList = CardCheck.tingPai(_player, DataManager.CurrenRoom) local isKan = false - for j=1,#player.fz_list do + for j = 1, #player.fz_list do if card == player.fz_list[j].card and player.fz_list[j].type == RB_FZType.Kan then - isKan =true + isKan = true end end if #tingList > 0 and isKan == false then - - mark_ting[#mark_ting+1] = card + mark_ting[#mark_ting + 1] = card end table.insert(player.handcard_list, card) - table.sort( player.handcard_list, ViewUtil.HandCardSort) + table.sort(player.handcard_list, ViewUtil.HandCardSort) end - -- print("ChuPaiTiShi",#mark_ting) - --pt(mark_ting) - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then - self._view :GetController("chupai").selectedIndex =1 - if #mark_ting>0 then - for i=1,#mark_ting do - for k=1,#self.card_list do - local card_view= self.card_list[k] + -- -- print("ChuPaiTiShi",#mark_ting) + --pt(mark_ting) + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + self._view:GetController("chupai").selectedIndex = 1 + if #mark_ting > 0 then + for i = 1, #mark_ting do + for k = 1, #self.card_list do + local card_view = self.card_list[k] if card_view.card_item == mark_ting[i] then card_view.btn_card:GetController("mark_ting").selectedIndex = 1 end @@ -491,13 +469,12 @@ end end end else - self._view :GetController("chupai").selectedIndex =0 - for k=1,#self.card_list do - local card_view= self.card_list[k] + self._view:GetController("chupai").selectedIndex = 0 + for k = 1, #self.card_list do + local card_view = self.card_list[k] card_view.btn_card:GetController("mark_ting").selectedIndex = 0 - end end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXGameController.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXGameController.lua index aa8327d3..81e93874 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXGameController.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXGameController.lua @@ -5,15 +5,15 @@ local M = {} --- Create a new HZ_GameController function M.new() - setmetatable(M,{__index = GameController}) - local self = setmetatable({}, {__index = M}) - self:init("汉寿跑胡子") - self.class = "RB_GameController" - return self + setmetatable(M, { __index = GameController }) + local self = setmetatable({}, { __index = M }) + self:init("汉寿跑胡子") + self.class = "RB_GameController" + return self end function M:init(name) - GameController.init(self,name) + GameController.init(self, name) self._eventmap[RB_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards self._eventmap[RB_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn @@ -31,80 +31,75 @@ function M:init(name) self._eventmap[RB_Protocol.GAME_EVT_RESULT1] = self.OneventResult1 self._eventmap[RB_Protocol.GAME_EVT_QIPAI] = self.OnEventQIPAI self._eventmap[RB_Protocol.GAME_EVT_ADD_CARD] = self.OnAddCard - - self._eventmap[RB_Protocol.GAME_EVT_Piao_Tip] = self.OnPiaoTip - self._eventmap[RB_Protocol.GAME_EVT_Piao_Action] = self.OnPiaoAction - self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai - self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim - -end + self._eventmap[RB_Protocol.GAME_EVT_Piao_Tip] = self.OnPiaoTip + self._eventmap[RB_Protocol.GAME_EVT_Piao_Action] = self.OnPiaoAction + self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai + self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim +end function M:SendXiPaiAction(callBack) printlog("jefe SendXiPaiAction===》》》》") local _data = {} - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_XIPAI, _data) - self.XiPaiCallBack=callBack + self.XiPaiCallBack = callBack end function M:OnEventXiPai(evt_data) - if evt_data["result"]==0 then - if self.XiPaiCallBack then - self.XiPaiCallBack() - end - else - ViewUtil.ErrorTip(1000000,"申请洗牌失败") - end - + if evt_data["result"] == 0 then + if self.XiPaiCallBack then + self.XiPaiCallBack() + end + else + ViewUtil.ErrorTip(1000000, "申请洗牌失败") + end end - function M:OnEventXiPaiAnim(evt_data) - printlog("jefe 洗牌动画===》》》》") - pt(evt_data) - local playeridList = evt_data["list"] - local my_isXiPai=false - local other_isXiPai=false - if playeridList and #playeridList>0 then - for i=1,#playeridList do - local p = self._room:GetPlayerById(playeridList[i]) - if p== self._room.self_player then - my_isXiPai=true - else - other_isXiPai=true - end - end - end - - self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventXiPai,my_isXiPai,other_isXiPai) - end) -end + printlog("jefe 洗牌动画===》》》》") + pt(evt_data) + local playeridList = evt_data["list"] + local my_isXiPai = false + local other_isXiPai = false + if playeridList and #playeridList > 0 then + for i = 1, #playeridList do + local p = self._room:GetPlayerById(playeridList[i]) + if p == self._room.self_player then + my_isXiPai = true + else + other_isXiPai = true + end + end + end + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.EventXiPai, my_isXiPai, other_isXiPai) + end) +end -- 发送出牌指令到服务器 function M:SendOutCard(card) local _data = {} _data["card"] = card local _room = self._room - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then _client:send(RB_Protocol.GAME_DIS_CARD, _data) end - end + --GAME_CHANGE_CARD GAME_DIS_CARD -function M:SendChangeCards( card_list ) +function M:SendChangeCards(card_list) local _data = {} if card_list then - _data["card_list"] = card_list - else - _data["card_list"]={} - end - local _client = ControllerManager.GameNetClinet + _data["card_list"] = card_list + else + _data["card_list"] = {} + end + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) + _client:send(RB_Protocol.GAME_CHANGE_CARD, _data) end end @@ -112,43 +107,40 @@ function M:SendChangeTypeFace(TypeFace) -- body local _data = {} _data["typeface"] = TypeFace - local _client = ControllerManager.GameNetClinet + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) + _client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data) end end - -function M:ConformToNextGame( ) - local _client = ControllerManager.GameNetClinet +function M:ConformToNextGame() + local _client = ControllerManager.GameNetClinet if _client ~= nil then - _client:send(RB_Protocol.GAME_EVT_CHUI) + _client:send(RB_Protocol.GAME_EVT_CHUI) end end -- 发送放子选择到服务器 -function M:SendAction(id,num) +function M:SendAction(id, num) local _data = {} _data["id"] = id - if num ~=nil then + if num ~= nil then _data["biid"] = num end local _client = ControllerManager.GameNetClinet - if _client ~= nil then - _client:send(RB_Protocol.GAME_ACTION, _data) + if _client ~= nil then + _client:send(RB_Protocol.GAME_ACTION, _data) end end - -function M:SendPiao(piao,callBack) +function M:SendPiao(piao, callBack) local _data = {} _data["id"] = piao local _client = ControllerManager.GameNetClinet _client:send(RB_Protocol.GAME_EVT_Send_Piao, _data) - self.PiaoTipsCallBack=callBack + self.PiaoTipsCallBack = callBack end - function M:OnPiaoTip(evt_data) if ViewManager.GetCurrenView().dview_class == LobbyView then self:ReturnToRoom() @@ -159,8 +151,8 @@ function M:OnPiaoTip(evt_data) local reload = evt_data["reload"] self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoTips, piao,reload) - ControllerManager.IsSendCard=true + DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoTips, piao, reload) + ControllerManager.IsSendCard = true end ) end @@ -168,51 +160,50 @@ end function M:OnPiaoAction(evt_data) local seat = evt_data["seat"] local piao = evt_data["piao"] - if seat==DataManager.CurrenRoom.self_player.seat then - if self.PiaoTipsCallBack then - self.PiaoTipsCallBack() - self.PiaoTipsCallBack=nil - end - end + if seat == DataManager.CurrenRoom.self_player.seat then + if self.PiaoTipsCallBack then + self.PiaoTipsCallBack() + self.PiaoTipsCallBack = nil + end + end self._cacheEvent:Enqueue( function() - DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoAction, seat,piao) + DispatchEvent(self._dispatcher, RB_GameEvent.OnPiaoAction, seat, piao) end ) end - function M:OnEventSendCards(evt_data) - printlog("jefe 发牌事件===》》》") - pt(evt_data) + printlog("jefe 发牌事件===》》》") + pt(evt_data) if ViewManager.GetCurrenView().dview_class == LobbyView then self:ReturnToRoom() return end - - local _room = self._room - _room.self_player.currentNotPutCardList={} + + local _room = self._room + _room.self_player.currentNotPutCardList = {} _room.curren_round = _room.curren_round + 1 if _room.curren_round > 0 then _room.playing = true end - - local handcards = {} - if evt_data.card_list and #evt_data.card_list>0 then - handcards = evt_data["card_list"] - else - ViewUtil.ErrorTip(100000,"发牌数据异常") - end - + + local handcards = {} + if evt_data.card_list and #evt_data.card_list > 0 then + handcards = evt_data["card_list"] + else + ViewUtil.ErrorTip(100000, "发牌数据异常") + end + local p = _room.self_player - local seat =nil - if evt_data.bank_seat then - seat = evt_data["bank_seat"] - else - ViewUtil.ErrorTip(100001,"发牌座位异常") - end - + local seat = nil + if evt_data.bank_seat then + seat = evt_data["bank_seat"] + else + ViewUtil.ErrorTip(100001, "发牌座位异常") + end + _room.banker_seat = seat - for i=1,#_room.player_list do - _room.self_player.handcard_list ={} + for i = 1, #_room.player_list do + _room.self_player.handcard_list = {} _room.self_player.card_list = {} _room.player_list[i].hand_left_count = 20 _room.player_list[i].fz_list = {} @@ -221,12 +212,12 @@ function M:OnEventSendCards(evt_data) _room.player_list[i].hu_xi = 0 end self._cacheEvent:Enqueue(function() - _room.self_player.handcard_list=handcards + _room.self_player.handcard_list = handcards self._room.self_player.hand_left_count = #handcards - DispatchEvent(self._dispatcher,RB_GameEvent.SendCards, p) - --print("发牌结束=====打开标志") - ControllerManager.IsSendCard=true - end) + DispatchEvent(self._dispatcher, RB_GameEvent.SendCards, p) + ---- print("发牌结束=====打开标志") + ControllerManager.IsSendCard = true + end) end function M:OnEventOutCard(evt_data) @@ -234,13 +225,13 @@ function M:OnEventOutCard(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(seat == _room.self_player.seat) then - list_remove(_room.self_player.handcard_list,card) + local _room = self._room + if (seat == _room.self_player.seat) then + list_remove(_room.self_player.handcard_list, card) end p.DiceCard = card - p.hand_left_count = p.hand_left_count -1 - DispatchEvent(self._dispatcher,RB_GameEvent.OutCard, p,card) + p.hand_left_count = p.hand_left_count - 1 + DispatchEvent(self._dispatcher, RB_GameEvent.OutCard, p, card) end) end @@ -249,10 +240,10 @@ function M:OnEventQIPAI(evt_data) local card = evt_data["card"] local p = self._room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - local _room = self._room - if(not p.outcard_list) then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card - DispatchEvent(self._dispatcher,RB_GameEvent.QiCard, seat,card) + local _room = self._room + if (not p.outcard_list) then p.outcard_list = {} end + p.outcard_list[#p.outcard_list + 1] = card + DispatchEvent(self._dispatcher, RB_GameEvent.QiCard, seat, card) end) end @@ -263,10 +254,10 @@ function M:OnEventTakeCard(evt_data) local left_count = evt_data["left_count"] local p = _room:GetPlayerBySeat(seat) self._cacheEvent:Enqueue(function() - if card ~=0 then + if card ~= 0 then p.DiceCard = card end - DispatchEvent(self._dispatcher,RB_GameEvent.GetCard, seat, card, left_count) + DispatchEvent(self._dispatcher, RB_GameEvent.GetCard, seat, card, left_count) end) end @@ -275,67 +266,64 @@ function M:OnAddCard(evt_data) local seat = evt_data["seat"] local card = evt_data["card"] local p = _room:GetPlayerBySeat(seat) - + self._cacheEvent:Enqueue(function() p.DiceCard = 0 - p.hand_left_count = p.hand_left_count +1 + p.hand_left_count = p.hand_left_count + 1 if (seat == _room.self_player.seat) then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - DispatchEvent(self._dispatcher,RB_GameEvent.AddCard, seat, card) + DispatchEvent(self._dispatcher, RB_GameEvent.AddCard, seat, card) end) end function M:OnEventOutHint(evt_data) - printlog("出牌提示事件===》》》") - pt(evt_data) - self._cacheEvent:Enqueue(function() - - DispatchEvent(self._dispatcher,RB_GameEvent.OutHint) + printlog("出牌提示事件===》》》") + pt(evt_data) + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, RB_GameEvent.OutHint) end) - end function M:OnEventTurn(evt_data) local seat = evt_data["seat"] self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.EventTurn, seat) + DispatchEvent(self._dispatcher, RB_GameEvent.EventTurn, seat) end) end function M:OnEventFzTips(evt_data) - printlog("放子提示事件===》》》") - pt(evt_data) + printlog("放子提示事件===》》》") + pt(evt_data) self._cacheEvent:Enqueue(function() local tiplist = FZTipList.new() - local list = evt_data["tip_list"] - local uid = evt_data["uid"] - for i=1,#list do - local dtip = list[i] - local tip = {} - tip.id = dtip["id"] - tip.weight = dtip["weight"] - tip.card = dtip["card"] - tip.type = dtip["type"] - tip.bi_list = dtip["bi_list"] - if (dtip["opcard"]) then - local opcard = dtip["opcard"] - tip.OpCard = opcard - table.sort(tip.OpCard) - tip.OpCard[3] = tip.Card - end - tiplist:AddTip(tip) - + local list = evt_data["tip_list"] + local uid = evt_data["uid"] + for i = 1, #list do + local dtip = list[i] + local tip = {} + tip.id = dtip["id"] + tip.weight = dtip["weight"] + tip.card = dtip["card"] + tip.type = dtip["type"] + tip.bi_list = dtip["bi_list"] + if (dtip["opcard"]) then + local opcard = dtip["opcard"] + tip.OpCard = opcard + table.sort(tip.OpCard) + tip.OpCard[3] = tip.Card end - DispatchEvent(self._dispatcher,RB_GameEvent.FZTips, tiplist,uid) + tiplist:AddTip(tip) + end + DispatchEvent(self._dispatcher, RB_GameEvent.FZTips, tiplist, uid) end) end function M:OnEventFzAction(evt_data) - printlog("放子行为提示事件===》》》") - pt(evt_data) + printlog("放子行为提示事件===》》》") + pt(evt_data) local _room = self._room - _room.self_player.currentNotPutCardList=evt_data["notput"] + _room.self_player.currentNotPutCardList = evt_data["notput"] local playerid = evt_data["playerid"] local card = evt_data["card"] local actice_card = evt_data["active_card"] @@ -345,181 +333,173 @@ function M:OnEventFzAction(evt_data) local huxi = evt_data["hu_xi"] local p = _room:GetPlayerById(playerid) self._cacheEvent:Enqueue(function() - local isNeedDelHandCard =0 - p.hu_xi = huxi - local fz = {} - fz.card = card - fz.type = ftype - fz.active_card = actice_card - fz.from_seat = from_seat - fz.opcard =opcard - local remove_num = #opcard - if ftype == RB_FZType.Chi then - p.fz_list[#p.fz_list+1] = fz + local isNeedDelHandCard = 0 + p.hu_xi = huxi + local fz = {} + fz.card = card + fz.type = ftype + fz.active_card = actice_card + fz.from_seat = from_seat + fz.opcard = opcard + local remove_num = #opcard + if ftype == RB_FZType.Chi then + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Bi then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - list_remove(_room.self_player.handcard_list,fz.card) + list_remove(_room.self_player.handcard_list, fz.card) end elseif ftype == RB_FZType.Peng then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end elseif ftype == RB_FZType.Kan then if (p == _room.self_player) then - if #opcard==2 then - _room.self_player.handcard_list[#_room.self_player.handcard_list+1] = card + if #opcard == 2 then + _room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card end - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz end elseif ftype == RB_FZType.ChouWei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,2 do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, 2 do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Wei then - p.fz_list[#p.fz_list+1] = fz + p.fz_list[#p.fz_list + 1] = fz if (p == _room.self_player) then - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end - end + end elseif ftype == RB_FZType.Pao then - - if (p == _room.self_player) then - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) - end - end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Pao - end - end - local num =0 - for i=1,#_room.self_player.handcard_list do - if card == _room.self_player.handcard_list[i] then - num=num+1 - end - end - if num>0 then - isNeedDelHandCard =num - - for i=1,num do - list_remove(_room.self_player.handcard_list,card) - end - local isAddTi =false - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - isAddTi=true - remove_num= 0 - end - end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz - end - end - - else - local num =0 - for i=1,#p.fz_list do - if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Pao - num=1 - remove_num= 0 - end - end - if num==0 then - p.fz_list[#p.fz_list+1] = fz - end - end - - elseif ftype == RB_FZType.Ti then - if (p == _room.self_player) then - for i=1,#p.fz_list do + for i = 1, #p.fz_list do if p.fz_list[i].card == card then if p.fz_list[i].type == RB_FZType.Kan then - isNeedDelHandCard =3 - for i=1,remove_num do - list_remove(_room.self_player.handcard_list,opcard[i]) + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) end end - remove_num= 0 - p.fz_list[i].type= RB_FZType.Ti + remove_num = 0 + p.fz_list[i].type = RB_FZType.Pao end end - local num =0 - for i=1,#_room.self_player.handcard_list do + local num = 0 + for i = 1, #_room.self_player.handcard_list do if card == _room.self_player.handcard_list[i] then - num=num+1 + num = num + 1 end end - if num>0 then - isNeedDelHandCard =num + if num > 0 then + isNeedDelHandCard = num - for i=1,num do - list_remove(_room.self_player.handcard_list,card) + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) end - local isAddTi =false - for i=1,#p.fz_list do + local isAddTi = false + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - isAddTi=true + p.fz_list[i].type = RB_FZType.Pao + isAddTi = true + remove_num = 0 end end - if isAddTi==false then - p.fz_list[#p.fz_list+1] = fz + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz end end - else - local num =0 - for i=1,#p.fz_list do + local num = 0 + for i = 1, #p.fz_list do if p.fz_list[i].card == card then - p.fz_list[i].type= RB_FZType.Ti - remove_num= 0 - num=1 + p.fz_list[i].type = RB_FZType.Pao + num = 1 + remove_num = 0 end end - if num==0 then - p.fz_list[#p.fz_list+1] = fz + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz end + end + elseif ftype == RB_FZType.Ti then + if (p == _room.self_player) then + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + if p.fz_list[i].type == RB_FZType.Kan then + isNeedDelHandCard = 3 + for i = 1, remove_num do + list_remove(_room.self_player.handcard_list, opcard[i]) + end + end + remove_num = 0 + p.fz_list[i].type = RB_FZType.Ti + end + end + local num = 0 + for i = 1, #_room.self_player.handcard_list do + if card == _room.self_player.handcard_list[i] then + num = num + 1 + end + end + if num > 0 then + isNeedDelHandCard = num - end - + for i = 1, num do + list_remove(_room.self_player.handcard_list, card) + end + local isAddTi = false + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + isAddTi = true + end + end + if isAddTi == false then + p.fz_list[#p.fz_list + 1] = fz + end + end + else + local num = 0 + for i = 1, #p.fz_list do + if p.fz_list[i].card == card then + p.fz_list[i].type = RB_FZType.Ti + remove_num = 0 + num = 1 + end + end + if num == 0 then + p.fz_list[#p.fz_list + 1] = fz + end + end end - - + + p.hand_left_count = p.hand_left_count - remove_num --[[if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti then coroutine.start(function() coroutine.wait(0.5) DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) - end) - else - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) + end) + else + DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) end--]] - DispatchEvent(self._dispatcher,RB_GameEvent.FangziAction, fz, p,isNeedDelHandCard) - + DispatchEvent(self._dispatcher, RB_GameEvent.FangziAction, fz, p, isNeedDelHandCard) end) end @@ -527,18 +507,18 @@ function M:OnEventHu(evt_data) local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) - -- print(win_p.hand_left_count) - + -- -- print(win_p.hand_left_count) + self._cacheEvent:Enqueue(function() win_p.card_list = cards - table.sort( win_p.card_list, ViewUtil.HandCardSort) - DispatchEvent(self._dispatcher,RB_GameEvent.ZPHuCard, evt_data["seat"],evt_data["from_seat"],cards) + table.sort(win_p.card_list, ViewUtil.HandCardSort) + DispatchEvent(self._dispatcher, RB_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards) end) end function M:OneventResult1(evt_data) - printlog("结算=============>>>") - pt(evt_data) + printlog("结算=============>>>") + pt(evt_data) local over = evt_data.type --0:小结算 1:小大结算 2:大结算 self._room.playing = false @@ -550,17 +530,17 @@ function M:OneventResult1(evt_data) p.outcard_list = {} end self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult1, result); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult1, result); end) elseif 1 == over or 2 == over then DataManager.CurrenRoom.Over = true - ControllerManager.SetGameNetClient(nil,true) + ControllerManager.SetGameNetClient(nil, true) local total_result = evt_data.total_result local result = evt_data.result self._cacheEvent:Enqueue(function() - DispatchEvent(self._dispatcher,RB_GameEvent.ZPResult2, result, total_result, over); + DispatchEvent(self._dispatcher, RB_GameEvent.ZPResult2, result, total_result, over); end) end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXMainView.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXMainView.lua index 6915bd49..1c1cfd58 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXMainView.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXMainView.lua @@ -22,8 +22,8 @@ local Fix_Msg_Chat = { --- Create a new ZZ_MainView function M.new() - setmetatable(M, {__index = ZPMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = ZPMainView }) + local self = setmetatable({}, { __index = M }) self.class = 'RunBeard_MainView' self._full = true self:init() @@ -37,6 +37,7 @@ function M:getCardItem(card_1, card_2) return card_1 .. '2_' .. card_2 end end + function M:InitView(url) local _room = self._room self.Fix_Msg_Chat = Fix_Msg_Chat @@ -48,9 +49,9 @@ function M:InitView(url) SettingView.onEXMainCallback = handler(self, self.UpdateCardDisplay) SettingView.onUpdataCardSizeCallback = handler(self, self.UpdateCardSize) - if DataManager.CurrenRoom.change_card_display==nil then - self:UpdateCardDisplay(2) - end + if DataManager.CurrenRoom.change_card_display == nil then + self:UpdateCardDisplay(2) + end for i = 1, #_room.player_list do local p = _room.player_list[i] local head = self._player_info[self:GetPos(p.seat)] @@ -123,120 +124,116 @@ function M:setBtn() end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end - function M:NewPlayerCardInfoView(view, index) if index == 1 then return PlayerSelfCardInfoView.new(view, self) end return PlayerCardInfoView.new(view, self) end + function M:closeTipOnTuoguan() if self._clearingView ~= nil then self._clearingView:Close() end self:__CloseTip() end + function M:EventInit() MainView.EventInit(self) local _room = self._room local _view = self._view local _player_info = self._player_info local _gamectr = self._gamectr - - _gamectr:AddEventListener(GameEvent.EventXiPai,function( ... ) - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] - self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - - end - - - if ( currentPlayer2 ) then - --self._popEvent = false - local xipaiCB2=function () - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end - - - end) - _gamectr:AddEventListener(GameEvent.OnPiaoTips, function(...) - local arg = {...} + _gamectr:AddEventListener(GameEvent.EventXiPai, function(...) + local arg = { ... } + local currentPlayer1 = arg[1] + local currentPlayer2 = arg[2] + self._popEvent = false + if (currentPlayer1) then + local xipaiCB = function() + self._popEvent = true + end + self:PlayXiPai(xipaiCB) + end + + + if (currentPlayer2) then + --self._popEvent = false + local xipaiCB2 = function() + self._popEvent = true + end + self:PlayXiPai1(xipaiCB2) + end + end) + + _gamectr:AddEventListener(GameEvent.OnPiaoTips, function(...) + local arg = { ... } local piao = arg[1] local reload = arg[2] - if reload==0 then - --self._popEvent = false - self._leftcard = 1 - self._leftcard = 1 - local rightpanel = self._view:GetChild('right_panel') - local tex_round = rightpanel:GetChild('tex_round') - if tex_round ~= nil then - tex_round.text = '第 ' .. _room.curren_round .. ' 局' - end - self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. '/' .. _room.room_config.round .. ' 局' + if reload == 0 then + --self._popEvent = false + self._leftcard = 1 + self._leftcard = 1 + local rightpanel = self._view:GetChild('right_panel') + local tex_round = rightpanel:GetChild('tex_round') + if tex_round ~= nil then + tex_round.text = '第 ' .. _room.curren_round .. ' 局' + end + self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. '/' .. _room.room_config.round .. ' 局' - self._state.selectedIndex = 1 - self:closeTipOnTuoguan() - local list = _room.player_list - for i = 1, #list do - local p = list[i] - p.hu_xi = 0 - local _info = self._player_card_info[self:GetPos(p.seat)] - _info:SetPlayer(p) - local info = self._player_info[self:GetPos(p.seat)] - info:FillData(p) - info:MarkBank(p.seat == _room.banker_seat) - info:Ready(false) - info:UpdatePiao(-1) - info._view:GetController('huxi').selectedIndex = 1 - info._view:GetChild('huxi').text = p.hu_xi - info._view:GetController('zhanji').selectedIndex = 0 + self._state.selectedIndex = 1 + self:closeTipOnTuoguan() + local list = _room.player_list + for i = 1, #list do + local p = list[i] + p.hu_xi = 0 + local _info = self._player_card_info[self:GetPos(p.seat)] + _info:SetPlayer(p) + local info = self._player_info[self:GetPos(p.seat)] + info:FillData(p) + info:MarkBank(p.seat == _room.banker_seat) + info:Ready(false) + info:UpdatePiao(-1) + info._view:GetController('huxi').selectedIndex = 1 + info._view:GetChild('huxi').text = p.hu_xi + info._view:GetController('zhanji').selectedIndex = 0 + + if _room.hpOnOff == 1 or _room:checkHpNonnegative() then + if p.total_hp == nil then + p.total_hp = 0 + end + info._view:GetController('zhanji').selectedIndex = 1 + info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) + end + end + end + --local card_info = self._player_card_info[1] + --card_info:UpdateIsOnClick(false) + --card_info:InitHandCard(true) + printlog("飘分提示==>>>") + + self._player_card_info[1]:ShowPiao(piao) + end) - if _room.hpOnOff == 1 or _room:checkHpNonnegative() then - if p.total_hp == nil then - p.total_hp = 0 - end - info._view:GetController('zhanji').selectedIndex = 1 - info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) - end - end - - end - --local card_info = self._player_card_info[1] - --card_info:UpdateIsOnClick(false) - --card_info:InitHandCard(true) - printlog("飘分提示==>>>") - - self._player_card_info[1]:ShowPiao(piao) - end) - _gamectr:AddEventListener(GameEvent.OnPiaoAction, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local piao = arg[2] local head_info = self._player_info[self:GetPos(seat)] head_info:UpdatePiao(piao) end) - + _gamectr:AddEventListener( GameEvent.SendCards, function(...) @@ -283,7 +280,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.GetCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] local _leftcard = arg[3] @@ -309,7 +306,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.AddCard, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] self._popEvent = false @@ -330,7 +327,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.EventTurn, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local list = _room.player_list local readyNum = 0 @@ -362,7 +359,7 @@ function M:EventInit() function(...) self:__CloseTip() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -399,7 +396,7 @@ function M:EventInit() self:__CloseTip() self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] local p = _room:GetPlayerBySeat(seat) @@ -413,7 +410,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local _uid = arg[2] self:__FangziTip(_tip, _uid) @@ -428,7 +425,7 @@ function M:EventInit() self._left_time = 0 self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local w = arg[1] local l = arg[2] local cards = arg[3] @@ -464,7 +461,7 @@ function M:EventInit() function(...) self._popEvent = false self._left_time = 0 - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -543,7 +540,7 @@ function M:EventInit() GameEvent.ZPResult2, function(...) self._left_time = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -574,8 +571,8 @@ end function M:ChangeCards(list) local _gamectr = ControllerManager.GetController(GameController) if _gamectr then - _gamectr:SendChangeCards(list) - end + _gamectr:SendChangeCards(list) + end end function M:__FangziTip(tip, _uid) @@ -599,12 +596,12 @@ function M:__FangziTip(tip, _uid) local td = tip.tip_map_type[_tlist[k]][1] local url = 'ui://Main_RunBeard/Btn_fztip' local btn_t = _lit_fanzi:AddItemFromPool(url) - if td.type==8 then - btn_t:GetChild("hupai").icon="ui://Main_RunBeard/201_1_" .. td.card - btn_t:GetController("hupai").selectedIndex=1 - end + if td.type == 8 then + btn_t:GetChild("hupai").icon = "ui://Main_RunBeard/201_1_" .. td.card + btn_t:GetController("hupai").selectedIndex = 1 + end btn_t.icon = 'ui://Main_RunBeard/newop_' .. td.type - btn_t.data = {tip, td, tip_hu} + btn_t.data = { tip, td, tip_hu } btn_t.onClick:Set(self.__TipAction, self) end if p.hand_left_count ~= 0 then @@ -637,6 +634,7 @@ function M:__FangziTip(tip, _uid) _chipeng_tip.x = _chipeng_tip.x + 200 _chipeng_tip.y = _chipeng_tip.y - 50 end + function M:__TipAction(context) local data = context.sender.data local _gamectr = self._gamectr @@ -825,13 +823,13 @@ function M:deepcopy(object) end function M:OnFangziAction(...) - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] local num = arg[3] --if fz.type == RB_FZType.Peng or fz.type == RB_FZType.Chi or fz.type == RB_FZType.Bi then - self:__CloseTip() + self:__CloseTip() --end if (player == self._room.self_player) then local info = _player_card_info[self:GetPos(player.seat)] @@ -918,7 +916,7 @@ function M:OnFangziAction(...) elseif fz.type == RB_FZType.Ti then self:PlaySound(player.self_user.sex, 'F_SaoChuan') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'ti') - -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti") + -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti") end effect.touchable = false effect.x, effect.y = 0, 0 @@ -950,15 +948,15 @@ function M:OnFangziAction(...) for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] - --print(p.hu_xi) + ---- print(p.hu_xi) info._view:GetChild('huxi').text = p.hu_xi end - - if player == self._room.self_player then - local info = _player_card_info[self:GetPos(player.seat)] - info:SetNotPutCard() - end - + + if player == self._room.self_player then + local info = _player_card_info[self:GetPos(player.seat)] + info:SetNotPutCard() + end + self._popEvent = true coroutine.start( function() @@ -993,13 +991,13 @@ function M:ReloadRoom() else self._player_info[self:GetPos(p.seat)]:Ready(false) end - - --if p.piao then - -- self._player_info[self:GetPos(p.seat)]:UpdatePiao(-1) - --else - self._player_info[self:GetPos(p.seat)]:UpdatePiao(p.piao) - --end - + + --if p.piao then + -- self._player_info[self:GetPos(p.seat)]:UpdatePiao(-1) + --else + self._player_info[self:GetPos(p.seat)]:UpdatePiao(p.piao) + --end + if self._state.selectedIndex == 1 then local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('huxi').selectedIndex = 1 @@ -1028,8 +1026,8 @@ function M:ReloadRoom() card_info:ChuPaiTiShi() if self._room.self_player.card_list ~= nil and - #self._room.self_player.handcard_list == #self._room.self_player.card_list - then + #self._room.self_player.handcard_list == #self._room.self_player.card_list + then local _list = self:deepcopy(self._room.self_player.card_list) local cards = {} for i = 1, #_list do diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXPlayBackView.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXPlayBackView.lua index 4371e666..cec497bc 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXPlayBackView.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/EXPlayBackView.lua @@ -21,8 +21,8 @@ end --- Create a new function M.new() - setmetatable(M, {__index = PlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = 'PlayBackView' self:init() @@ -185,7 +185,7 @@ function M:ShowStep(index) self._room.self_player.handcard_list = p.card_list info:InitHandCard(false) end - + --[[if step.cmd == Record_Event.Evt_ChangePaiXing then local _card_list = {} for i = 1, #step.card_list do @@ -202,7 +202,7 @@ function M:ShowStep(index) info:UpdateHandCards(step.card_list) end end--]] - + if step.cmd == Record_Event.Evt_OutCard or step.cmd == Record_Event.Evt_GetCard then if step.DiceCard ~= nil and step.DiceCard ~= 0 then if p.seat == step.seat then @@ -220,7 +220,7 @@ function M:ShowStep(index) info:UpdateQiPai(p.outcard_list) end end - -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) + -- -- print("step.cmd ",step.cmdm,Record_Event.Evt_Win) if step.cmd == Record_Event.Evt_result then --[[local _room = DataManager.CurrenRoom local result = step.result @@ -325,6 +325,7 @@ function M:CmdGetCard(cmd, index) data.seat = cmd.seat data.DiceCard = cmd.data.card end + function M:CmdThrowCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd @@ -334,6 +335,7 @@ function M:CmdThrowCard(cmd, index) data.out_card_list = cmd.data.card u.outcard_list[#u.outcard_list + 1] = cmd.data.card end + function M:CmdAddCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd diff --git a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/PlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/PlayerSelfCardInfoView.lua index 2bd0e0e5..2e70263e 100644 --- a/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/PlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/zipai/yueyangwaihuzi_bak/PlayerSelfCardInfoView.lua @@ -1,10 +1,10 @@ local PlayerSelfCardInfoView = import(".main.ZPPlayerSelfCardInfoView") local CardCheck = import(".main.CardCheck") local M = {} --- -function M.new(view,mainView) - setmetatable(M, {__index = PlayerSelfCardInfoView}) - local self = setmetatable({},{__index = M}) +-- +function M.new(view, mainView) + setmetatable(M, { __index = PlayerSelfCardInfoView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView @@ -13,52 +13,50 @@ function M.new(view,mainView) return self end - function M:onTouchBegin(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local button = context.sender local card = button.data - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self:ShowHuTip(card.card_item) end - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", card.card_item) card.btn_card.sortingOrder = 100 - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) - card.btn_card.xy = Vector2.New(card.btn_card.x+20 ,card.btn_card.y-50) + local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50) card.touch_pos = xy - button.xy - end function M:ClearMpList(mpList) - local tempList={} - for k,v in pairs(mpList) do - if #v>0 then - table.insert(tempList,v) - end - end - - return tempList + local tempList = {} + for k, v in pairs(mpList) do + if #v > 0 then + table.insert(tempList, v) + end + end + + return tempList end function M:__OnDragEnd(context) - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end local button = context.sender - + local card = button.data - + local _room = DataManager.CurrenRoom card.btn_card.sortingOrder = 0 - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) - local currentCtrS=IsHasDictionary(card.card_item,DataManager.CurrenRoom.self_player.currentNotPutCardList) - if currentCtrS==nil then currentCtrS=false end - if (button.y < -380 and _room.curren_outcard_seat == _room.self_player.seat) and currentCtrS==false then + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + local currentCtrS = IsHasDictionary(card.card_item, DataManager.CurrenRoom.self_player.currentNotPutCardList) + if currentCtrS == nil then currentCtrS = false end + if (button.y < -380 and _room.curren_outcard_seat == _room.self_player.seat) and currentCtrS == false then button.touchable = false self.outcard_button = card self:UpdateIsOnClick(false) @@ -66,7 +64,7 @@ function M:__OnDragEnd(context) else local isChangeCard = false self.outcard_button = nil - card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_",card.card_item) + card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/201_", card.card_item) self._area_handcard_list:AddChild(button) if #self.card_list == 1 then isChangeCard = false @@ -74,194 +72,189 @@ function M:__OnDragEnd(context) return end local CountCards = {} - for i=1,#self.card_list do + for i = 1, #self.card_list do local lists = {} if CountCards[self.card_list[i].index_X] == nil then - lists[#lists+1] = self.card_list[i] - CountCards[self.card_list[i].index_X]= lists + lists[#lists + 1] = self.card_list[i] + CountCards[self.card_list[i].index_X] = lists else - CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X]+1] =self.card_list[i] + CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X] + 1] = self.card_list[i] end end - - CountCards=self:ClearMpList(CountCards) - + + CountCards = self:ClearMpList(CountCards) + local minmark = 1 local maxmark = #self.card_list - if card == self.card_list[1] or card == self.card_list[#self.card_list] then + if card == self.card_list[1] or card == self.card_list[#self.card_list] then if self.card_list[1].index_X == self.card_list[2].index_X then - minmark =2 + minmark = 2 end - if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list-1].index_X then - maxmark =#self.card_list-1 + if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list - 1].index_X then + maxmark = #self.card_list - 1 end end - if button.x+button.width/2 < self.card_list[minmark].btn_card.x and #CountCards<12 then - list_remove(self.card_list,card) + if button.x + button.width / 2 < self.card_list[minmark].btn_card.x and #CountCards < 12 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X < card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X + 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X < card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X + 1 + end end else - for i=1,#self.card_list do - self.card_list[i].index_X = self.card_list[i].index_X + 1 + for i = 1, #self.card_list do + self.card_list[i].index_X = self.card_list[i].index_X + 1 end end - card.index_X =1 - card.index_Y =1 - table.insert(self.card_list,1,card) + card.index_X = 1 + card.index_Y = 1 + table.insert(self.card_list, 1, card) isChangeCard = true - elseif button.x+button.width/2 > (self.card_list[maxmark].btn_card.x +button.width) and #CountCards<12 then - list_remove(self.card_list,card) + elseif button.x + button.width / 2 > (self.card_list[maxmark].btn_card.x + button.width) and #CountCards < 12 then + list_remove(self.card_list, card) local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end end - card.index_X =self.card_list[#self.card_list].index_X+1 - card.index_Y =1 - self.card_list[#self.card_list+1] =card + card.index_X = self.card_list[#self.card_list].index_X + 1 + card.index_Y = 1 + self.card_list[#self.card_list + 1] = card isChangeCard = true - else + else local MoveCard = false local MoveCardPos = 0 local MoveCardY = 0 - for i=1,#CountCards do - if CountCards[i] then - local card_view = CountCards[i][1] - if card_view~=nil then - if button.x+button.width/2 > card_view.old_postion.x and button.x+button.width/2 < (card_view.old_postion.x+button.width) then - if card ~= card_view and #CountCards[i] <4 and card.index_X ~= card_view.index_X then - - MoveCardPos = i - MoveCardY = #CountCards[i]+1 - MoveCard = true - list_remove(self.card_list,card) - end - end - end - end - - end - local MoveCardindex = 0 - -- local MoveCardY = 0 - if button.x+button.width/2 > card.old_postion.x and button.x+button.width/2 < (card.old_postion.x+button.width) then - if #CountCards[card.index_X]>1 then - for i=1,#CountCards[card.index_X] do - local _cv = CountCards[card.index_X][i] - if _cv ~= card then - if button.y+button.height/2 > _cv.btn_card.y and button.y+button.height/2 < (_cv.btn_card.y+button.height) then - --向下移動 - if ((button.y+button.height/2) +20) > (card.old_postion.y+button.height) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - --向上移動 - elseif ((button.y+button.height/2) -20) < card.old_postion.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - end - elseif i == #CountCards[card.index_X] and button.y+button.height/2 < _cv.btn_card.y then - MoveCardindex = 1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) - elseif i == 1 and button.y+button.height/2 > (_cv.btn_card.y+button.width) then - MoveCardindex = -1 - MoveCardPos = card.index_X - MoveCardY = _cv.index_Y - MoveCard = true - list_remove(self.card_list,card) + for i = 1, #CountCards do + if CountCards[i] then + local card_view = CountCards[i][1] + if card_view ~= nil then + if button.x + button.width / 2 > card_view.old_postion.x and button.x + button.width / 2 < (card_view.old_postion.x + button.width) then + if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then + MoveCardPos = i + MoveCardY = #CountCards[i] + 1 + MoveCard = true + list_remove(self.card_list, card) end end end end - end - if MoveCard ==true and MoveCardindex ==0 then + local MoveCardindex = 0 + -- local MoveCardY = 0 + if button.x + button.width / 2 > card.old_postion.x and button.x + button.width / 2 < (card.old_postion.x + button.width) then + if #CountCards[card.index_X] > 1 then + for i = 1, #CountCards[card.index_X] do + local _cv = CountCards[card.index_X][i] + if _cv ~= card then + if button.y + button.height / 2 > _cv.btn_card.y and button.y + button.height / 2 < (_cv.btn_card.y + button.height) then + --向下移動 + if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + --向上移動 + elseif ((button.y + button.height / 2) - 20) < card.old_postion.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + end + elseif i == #CountCards[card.index_X] and button.y + button.height / 2 < _cv.btn_card.y then + MoveCardindex = 1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + elseif i == 1 and button.y + button.height / 2 > (_cv.btn_card.y + button.width) then + MoveCardindex = -1 + MoveCardPos = card.index_X + MoveCardY = _cv.index_Y + MoveCard = true + list_remove(self.card_list, card) + end + end + end + end + end + if MoveCard == true and MoveCardindex == 0 then local num = 0 - for i=1,#self.card_list do + for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then - num = num+1 + num = num + 1 end end - if num ==0 then - for i=1,#self.card_list do - if self.card_list[i].index_X > card.index_X then - self.card_list[i].index_X = self.card_list[i].index_X - 1 - end + if num == 0 then + for i = 1, #self.card_list do + if self.card_list[i].index_X > card.index_X then + self.card_list[i].index_X = self.card_list[i].index_X - 1 + end end if MoveCardPos > card.index_X then - MoveCardPos = MoveCardPos-1 + MoveCardPos = MoveCardPos - 1 end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do if MoveCardPos == self.card_list[i].index_X then - table.insert(self.card_list,(i+1),card) + table.insert(self.card_list, (i + 1), card) break end end isChangeCard = true - --上下移动 - elseif MoveCard ==true and MoveCardindex ~= 0 then - for i=1,#self.card_list do - if card.index_X == self.card_list[i].index_X then + --上下移动 + elseif MoveCard == true and MoveCardindex ~= 0 then + for i = 1, #self.card_list do + if card.index_X == self.card_list[i].index_X then --向下移动 if MoveCardindex == -1 then - if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then + if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then self.card_list[i].index_Y = self.card_list[i].index_Y + 1 - end - --向上移动 + --向上移动 else - if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then - self.card_list[i].index_Y = self.card_list[i].index_Y - 1 - + if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then + self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end end end - card.index_X =MoveCardPos - card.index_Y =MoveCardY - for i=#self.card_list,1,-1 do - if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY-1) then - table.insert(self.card_list,(i+1),card) + card.index_X = MoveCardPos + card.index_Y = MoveCardY + for i = #self.card_list, 1, -1 do + if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY - 1) then + table.insert(self.card_list, (i + 1), card) break - elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY+1) then - table.insert(self.card_list,i,card) + elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY + 1) then + table.insert(self.card_list, i, card) break end end @@ -270,186 +263,171 @@ function M:__OnDragEnd(context) isChangeCard = false self._area_handcard_list:AddChild(button) end - - end + end self:UpdateHandCardsPos() - if isChangeCard ==true then + if isChangeCard == true then self:SendChangeCard() end end end -function M:UpdateOutCardList(outcard,isShow,isMopai,seat) - if(isShow == nil) then - isShow = false +function M:UpdateOutCardList(outcard, isShow, isMopai, seat) + if (isShow == nil) then + isShow = false end - if(isMopai == nil) then - isMopai = false + if (isMopai == nil) then + isMopai = false end - self._area_outcard_list:RemoveChildren(0,-1,true) - local outcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") - - if outcard==0 then - outcards:GetChild("icon").icon ="ui://Main_RunBeard/202_1_300" + self._area_outcard_list:RemoveChildren(0, -1, true) + local outcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard") + + if outcard == 0 then + outcards:GetChild("icon").icon = "ui://Main_RunBeard/202_1_300" else - outcards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/203_",outcard) + outcards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/203_", outcard) end - outcards.x,outcards.y = 0,0 - local show_di_bg = outcards:GetChild("show_di_bg") - -- show_di_bg.visible = true - if(isShow)then - if outcard == 0 then - show_di_bg.visible = false - end - if(seat ~= nil and outcards~=nil)then - if(isMopai)then - if outcard ~= 0 then - outcards:GetTransition("mopai"..seat):Play(function( ) - -- show_di_bg.visible = true - - end) - end + outcards.x, outcards.y = 0, 0 + local show_di_bg = outcards:GetChild("show_di_bg") + -- show_di_bg.visible = true + if (isShow) then + if outcard == 0 then + show_di_bg.visible = false + end + if (seat ~= nil and outcards ~= nil) then + if (isMopai) then + if outcard ~= 0 then + outcards:GetTransition("mopai" .. seat):Play(function() + -- show_di_bg.visible = true + end) + end else - show_di_bg.visible = false - outcards:GetTransition("cpai"..seat):Play() + show_di_bg.visible = false + outcards:GetTransition("cpai" .. seat):Play() end - else - --show_di_bg.visible = true - end + else + --show_di_bg.visible = true + end else - show_di_bg.visible = false + show_di_bg.visible = false end self._area_outcard_list:AddChild(outcards) end --弃牌 -function M:UpdateQiPai( qi_list,isplay) - self._area_qipai_list:RemoveChildren(0,-1,true) - for i=1,#qi_list do - local qicards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") - qicards:GetChild("icon").icon =self:getCardItem("ui://Main_RunBeard/202_",qi_list[i]) - if(isplay)then - if(i == #qi_list) then - qicards:GetTransition("t0"):Play() +function M:UpdateQiPai(qi_list, isplay) + self._area_qipai_list:RemoveChildren(0, -1, true) + for i = 1, #qi_list do + local qicards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Qipai") + qicards:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeard/202_", qi_list[i]) + if (isplay) then + if (i == #qi_list) then + qicards:GetTransition("t0"):Play() end - end - self._area_qipai_list:AddChild(qicards) - end + end + self._area_qipai_list:AddChild(qicards) + end end --摸牌动画 -function M:PlayingOutCardAnima( card) +function M:PlayingOutCardAnima(card) coroutine.start(function() - coroutine.wait(0.1) + coroutine.wait(0.1) self:ClearOutCard() end) end -function M:UpdateFzList( fz_list ,ispaly) - - self._area_fz_list:RemoveChildren(0,-1,true) - for i = 1,#fz_list do - printlog("jefe UpdateFzList>>>",fz_list[i].type) - local fzitem=nil +function M:UpdateFzList(fz_list, ispaly) + self._area_fz_list:RemoveChildren(0, -1, true) + for i = 1, #fz_list do + printlog("jefe UpdateFzList>>>", fz_list[i].type) + local fzitem = nil if fz_list[i].type ~= RB_FZType.Kan then - fzitem =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") - if(ispaly == false)then - fzitem:RemoveChildren(0,-1,true) + fzitem = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew") + if (ispaly == false) then + fzitem:RemoveChildren(0, -1, true) end end if fz_list[i].type == RB_FZType.Chi or fz_list[i].type == RB_FZType.Bi then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - fzcards:GetChild("card_"..1).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].active_card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + fzcards:GetChild("card_" .. 1).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].active_card) fzcards:GetController("c2").selectedIndex = 1 - fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[1]) - fzcards:GetChild("card_"..3).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[2]) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 2).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[1]) + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].opcard[2]) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Peng then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,3 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Wei then - - --[[ local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + --[[ local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") fzcards:GetController("c1").selectedIndex=1 for j=1,3 do fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) end fzcards.x,fzcards.y = 0,0 self:playAnim(fzitem,fzcards,#fz_list,i,ispaly)--]] - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,3 do - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 3 do + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end - fzcards:GetChild("card_"..3).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.ChouWei then - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") - for j=1,2 do - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3") + for j = 1, 2 do + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end - fzcards:GetChild("card_"..3).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards:GetChild("card_" .. 3).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Pao then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Ti then - - local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") - for j=1,4 do - if j==4 then - fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card) + local fzcards = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_4") + for j = 1, 4 do + if j == 4 then + fzcards:GetChild("card_" .. j).icon = self:getCardItem("ui://Main_RunBeard/202_", fz_list[i].card) else - fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300" + fzcards:GetChild("card_" .. j).icon = "ui://Main_RunBeard/202_1_300" end end - fzcards.x,fzcards.y = 0,0 - self:playAnim(fzitem,fzcards,#fz_list,i,ispaly) - + fzcards.x, fzcards.y = 0, 0 + self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) end end end - -function M:playAnim( fzitem,fzcards, size,i,ispaly ) - if(ispaly == nil)then - ispaly =false - end - printlog("jefe playAnim>>>",fzcards,size,i) - if(ispaly and i == size)then - local faArray= fzitem:GetChild("chiwei") - if(faArray~=nil)then - faArray:AddChild(fzcards) - else - fzitem:AddChild(fzcards) - end - else - fzitem:AddChild(fzcards) - end - self._area_fz_list:AddChild(fzitem) +function M:playAnim(fzitem, fzcards, size, i, ispaly) + if (ispaly == nil) then + ispaly = false + end + printlog("jefe playAnim>>>", fzcards, size, i) + if (ispaly and i == size) then + local faArray = fzitem:GetChild("chiwei") + if (faArray ~= nil) then + faArray:AddChild(fzcards) + else + fzitem:AddChild(fzcards) + end + else + fzitem:AddChild(fzcards) + end + self._area_fz_list:AddChild(fzitem) end - - --出牌提示动画 - function M:ChuPaiTiShi() - if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then +--出牌提示动画 +function M:ChuPaiTiShi() + if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local chu_player = DataManager.CurrenRoom.self_player @@ -460,33 +438,32 @@ end selfplayeTable.paoCount = chu_player.paoCount selfplayeTable.hu_xi = chu_player.hu_xi local player = membe_deep_clone(selfplayeTable) - local mark_ting= {} - for i=1,#DataManager.CurrenRoom.self_player.handcard_list do - local card = DataManager.CurrenRoom.self_player.handcard_list[i] + local mark_ting = {} + for i = 1, #DataManager.CurrenRoom.self_player.handcard_list do + local card = DataManager.CurrenRoom.self_player.handcard_list[i] list_remove(player.handcard_list, card) local _player = membe_deep_clone(player) - local tingList = CardCheck.tingPai(_player,DataManager.CurrenRoom) + local tingList = CardCheck.tingPai(_player, DataManager.CurrenRoom) local isKan = false - for j=1,#player.fz_list do + for j = 1, #player.fz_list do if card == player.fz_list[j].card and player.fz_list[j].type == RB_FZType.Kan then - isKan =true + isKan = true end end if #tingList > 0 and isKan == false then - - mark_ting[#mark_ting+1] = card + mark_ting[#mark_ting + 1] = card end table.insert(player.handcard_list, card) - table.sort( player.handcard_list, ViewUtil.HandCardSort) + table.sort(player.handcard_list, ViewUtil.HandCardSort) end - -- print("ChuPaiTiShi",#mark_ting) - --pt(mark_ting) - if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then - self._view :GetController("chupai").selectedIndex =1 - if #mark_ting>0 then - for i=1,#mark_ting do - for k=1,#self.card_list do - local card_view= self.card_list[k] + -- -- print("ChuPaiTiShi",#mark_ting) + --pt(mark_ting) + if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then + self._view:GetController("chupai").selectedIndex = 1 + if #mark_ting > 0 then + for i = 1, #mark_ting do + for k = 1, #self.card_list do + local card_view = self.card_list[k] if card_view.card_item == mark_ting[i] then card_view.btn_card:GetController("mark_ting").selectedIndex = 1 end @@ -494,13 +471,12 @@ end end end else - self._view :GetController("chupai").selectedIndex =0 - for k=1,#self.card_list do - local card_view= self.card_list[k] + self._view:GetController("chupai").selectedIndex = 0 + for k = 1, #self.card_list do + local card_view = self.card_list[k] card_view.btn_card:GetController("mark_ting").selectedIndex = 0 - end end end -return M \ No newline at end of file +return M diff --git a/lua_probject/main_project/main/majiang/MJMainView.lua b/lua_probject/main_project/main/majiang/MJMainView.lua index 392ceb6b..a9f47975 100644 --- a/lua_probject/main_project/main/majiang/MJMainView.lua +++ b/lua_probject/main_project/main/majiang/MJMainView.lua @@ -59,8 +59,8 @@ function M:InitView(url, use_custom_bg) --local tempdsaf=self._view:GetChild("btn_back_jiesan") --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - --print("2222222222222222222222") - --print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name) + ---- print("2222222222222222222222") + ---- print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name) --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) --local temp111=self._view:GetChild("btn_back_jiesan").displayObject.gameObject --temp111:SetActive(false) diff --git a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua b/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua index 24e6a280..79680576 100644 --- a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua +++ b/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua @@ -143,10 +143,10 @@ function M:UpdateHandCard(getcard, mp) local handcard_list = self._mask_data['handcard_list'] local oder = handcard_list['oder'] local _player = self._player - -- print(vardump(self._player)) + -- -- print(vardump(self._player)) self._area_handcard_list:RemoveChildren(0, -1, true) - -- print(vardump(_player.card_list)) + -- -- print(vardump(_player.card_list)) if (not mp) then local comp_back = handcard_list['comp_back'] if self._current_card_type == 2 then @@ -178,8 +178,8 @@ function M:UpdateHandCard(getcard, mp) local outcard_list = self._mask_data['outcard_list'] local comp = handcard_list['comp'] local card = outcard_list['card'] - --print("comp"..comp) - -- print(vardump(_player.card_list)) + ---- print("comp"..comp) + -- -- print(vardump(_player.card_list)) if self._current_card_type == 2 then comp = comp .. '_3d' @@ -390,7 +390,7 @@ function M:UpdateFzList(fz, index, show_card) end local obj = UIPackage.CreateObjectFromURL('ui://Main_Majiang/' .. comp) - print("============================================pengpengpeng", comp) + -- print("============================================pengpengpeng", comp) local _area_fz_list = self._area_fz_list local _area_outcard_list = self._area_outcard_list diff --git a/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua b/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua index ce78fea8..122fe34b 100644 --- a/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua @@ -183,7 +183,7 @@ function M:__OnDragEnd(context) local _room = DataManager.CurrenRoom if not _room or _room:GetReloadStatus() then return end - -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) + -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then self._mainView:OutCard(card.card_item) button.touchable = false diff --git a/lua_probject/main_project/main/majiang/MJTableBG.lua b/lua_probject/main_project/main/majiang/MJTableBG.lua index 6104e6d5..f90df970 100644 --- a/lua_probject/main_project/main/majiang/MJTableBG.lua +++ b/lua_probject/main_project/main/majiang/MJTableBG.lua @@ -5,12 +5,12 @@ local MJTableBG = {} local M = MJTableBG local mj_bg_config = { - {id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04"}, - {id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05"}, - {id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06"}, - {id = 4, url = "base/main_majiang/bg/bg6", thumb = "ui://Main_Majiang/b01"}, - {id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02"}, - {id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03"}, + { id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04" }, + { id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05" }, + { id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06" }, + { id = 4, url = "base/main_majiang/bg/bg6", thumb = "ui://Main_Majiang/b01" }, + { id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02" }, + { id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03" }, } local function GetBG(data, game_id) @@ -39,7 +39,7 @@ local function SetBG(data, game_id, bg_id) if not contain_key then local _data = {} _data.game_id = game_id - _data.bg_id = bg_id + _data.bg_id = bg_id table.insert(data, _data) end end @@ -52,12 +52,12 @@ function MJTableBG.GetTableBG(game_id) local id = -1 local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code) - -- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id) - if json_data ~= nil then - local config_data = json.decode(json_data) - id = GetBG(config_data, game_id) - end - return id + -- -- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id) + if json_data ~= nil then + local config_data = json.decode(json_data) + id = GetBG(config_data, game_id) + end + return id end function MJTableBG.LoadTableBG(id, game_id, main_view) @@ -75,13 +75,13 @@ end function MJTableBG.SaveTableBG(game_id, bg_id) local config_data local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code) - if json_data ~= nil then - config_data = json.decode(json_data) - else - config_data = {} - end + if json_data ~= nil then + config_data = json.decode(json_data) + else + config_data = {} + end SetBG(config_data, game_id, bg_id) Utils.SaveLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code, json.encode(config_data)) end -return M \ No newline at end of file +return M diff --git a/lua_probject/main_project/main/zipai/CardCheck.lua b/lua_probject/main_project/main/zipai/CardCheck.lua index 38850d29..3af3e654 100644 --- a/lua_probject/main_project/main/zipai/CardCheck.lua +++ b/lua_probject/main_project/main/zipai/CardCheck.lua @@ -52,6 +52,7 @@ local M = { function M:push(cardGroup) self.stack[#self.stack + 1] = cardGroup end + function M:pushhuxi(cardGroup) self.stackHuxi[#self.stackHuxi + 1] = cardGroup end @@ -64,6 +65,7 @@ function M:rollBack() end table.sort(self.cardList) end + -- 顺子 function M:tryShunzi1(card, player) if card < 300 and card % 100 > 8 then @@ -73,7 +75,7 @@ function M:tryShunzi1(card, player) removeCard(self.cardList, card + 1, 1) removeCard(self.cardList, card + 2, 1) removeCard(self.cardList, card, 1) - local cardGroup = {card, card + 1, card + 2} + local cardGroup = { card, card + 1, card + 2 } self:push(cardGroup) local _huxi = 0 if card == 101 then @@ -94,7 +96,7 @@ function M:tryShunzi2(card) if checkCard(card + 100, self.cardList, 1) and checkCard(card, self.cardList, 2) then removeCard(self.cardList, card, 2) removeCard(self.cardList, card + 100, 1) - local cardGroup = {card, card, card + 100} + local cardGroup = { card, card, card + 100 } self:push(cardGroup) self:pushhuxi(0) return true @@ -102,7 +104,7 @@ function M:tryShunzi2(card) if (checkCard(card + 100, self.cardList, 2)) and (checkCard(card, self.cardList, 1)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 100, 2) - local cardGroup = {card, card + 100, card + 100} + local cardGroup = { card, card + 100, card + 100 } self:push(cardGroup) self:pushhuxi(0) return true @@ -111,7 +113,7 @@ function M:tryShunzi2(card) if (checkCard(card - 100, self.cardList, 1)) and checkCard(card, self.cardList, 2) then removeCard(self.cardList, card, 2) removeCard(self.cardList, card - 100, 1) - local cardGroup = {card - 100, card, card} + local cardGroup = { card - 100, card, card } self:push(cardGroup) self:pushhuxi(0) return true @@ -119,13 +121,13 @@ function M:tryShunzi2(card) if (checkCard(card - 100, self.cardList, 2)) and checkCard(card, self.cardList, 1) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card - 100, 2) - local cardGroup = {card, card - 100, card - 100} + local cardGroup = { card, card - 100, card - 100 } self:push(cardGroup) self:pushhuxi(0) return true end end - --print(card) + ---- print(card) return false -- body end @@ -137,7 +139,7 @@ function M:tryShunzi3(card, player) removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 5, 1) removeCard(self.cardList, card + 8, 1) - local cardGroup = {card, card + 5, card + 8} + local cardGroup = { card, card + 5, card + 8 } self:push(cardGroup) local _huxi = 0 if card == 102 then @@ -151,11 +153,12 @@ function M:tryShunzi3(card, player) end return false end + -- 坎 function M:tryKezi(card, player) if (checkCard(card, self.cardList, 3)) then removeCard(self.cardList, card, 3) - local cardGroup = {card, card, card} + local cardGroup = { card, card, card } self:push(cardGroup) local _huxi = 0 if card < 200 then @@ -166,7 +169,7 @@ function M:tryKezi(card, player) self:pushhuxi(_huxi) return true end - -- print(card) + -- -- print(card) return false end @@ -176,12 +179,12 @@ function M:tryPair(card) end if (checkCard(card, self.cardList, 2)) then removeCard(self.cardList, card, 2) - local cardGroup = {card, card} + local cardGroup = { card, card } self:push(cardGroup) self.pair_count = 1 return true end - -- print(card) + -- -- print(card) return false end @@ -330,7 +333,7 @@ local function init(self, player, cardInhand, addCard) end function M.tingPai(player, room) - local self = setmetatable({}, {__index = M}) + local self = setmetatable({}, { __index = M }) local tingList = {} local cardInhand = player.handcard_list if not cardInhand or #cardInhand == 0 then @@ -389,8 +392,8 @@ function M.tingPai(player, room) end if (num2 + player.hu_xi + kan_huxi + self:GetFzData(tem, ctype)) >= - (self:getHuxi(room)) - then + (self:getHuxi(room)) + then tingList[#tingList + 1] = tem end end @@ -413,13 +416,13 @@ function M.tingPai(player, room) end function M:getHuxi(room) - if room.game_id == 301 then - return 8 - end + if room.game_id == 301 then + return 8 + end if room.game_id == 15 then return 15 end - if room.game_id == 13 or room.game_id == 14 or room.game_id == 23 then + if room.game_id == 13 or room.game_id == 14 or room.game_id == 23 then return 15 elseif room.game_id == 26 then return 10 diff --git a/lua_probject/tolua_project/cjson/util.lua b/lua_probject/tolua_project/cjson/util.lua index 6916dad0..dceb34cd 100644 --- a/lua_probject/tolua_project/cjson/util.lua +++ b/lua_probject/tolua_project/cjson/util.lua @@ -186,7 +186,7 @@ local function run_test(testname, func, input, should_work, output) if status ~= nil then name = name .. statusmap[status] end - print(("[%s] %s"):format(name, serialise_value(value, false))) + -- print(("[%s] %s"):format(name, serialise_value(value, false))) end local result = { pcall(func, unpack(input)) } @@ -200,7 +200,7 @@ local function run_test(testname, func, input, should_work, output) test_count_total = test_count_total + 1 local teststatus = { [true] = "PASS", [false] = "FAIL" } - print(("==> Test [%d] %s: %s"):format(test_count_total, testname, + -- print(("==> Test [%d] %s: %s"):format(test_count_total, testname, teststatus[correct])) status_line("Input", nil, input) @@ -208,7 +208,7 @@ local function run_test(testname, func, input, should_work, output) status_line("Expected", should_work, output) end status_line("Received", success, result) - print() + -- print() return correct, result end @@ -216,11 +216,11 @@ end local function run_test_group(tests) local function run_helper(name, func, input) if type(name) == "string" and #name > 0 then - print("==> " .. name) + -- print("==> " .. name) end -- Not a protected call, these functions should never generate errors. func(unpack(input or {})) - print() + -- print() end for _, v in ipairs(tests) do diff --git a/lua_probject/tolua_project/event.lua b/lua_probject/tolua_project/event.lua index fb3db8a0..a2060905 100644 --- a/lua_probject/tolua_project/event.lua +++ b/lua_probject/tolua_project/event.lua @@ -17,50 +17,50 @@ local ilist = ilist local _xpcall = {} -_xpcall.__call = function(self, ...) +_xpcall.__call = function(self, ...) if jit then if nil == self.obj then - return xpcall(self.func, traceback, ...) - else - return xpcall(self.func, traceback, self.obj, ...) + return xpcall(self.func, traceback, ...) + else + return xpcall(self.func, traceback, self.obj, ...) end else - local args = {...} + local args = { ... } if nil == self.obj then local func = function() self.func(unpack(args, 1, maxn(args))) end - return xpcall(func, traceback) - else + return xpcall(func, traceback) + else local func = function() self.func(self.obj, unpack(args, 1, maxn(args))) end return xpcall(func, traceback) end - end + end end _xpcall.__eq = function(lhs, rhs) return lhs.func == rhs.func and lhs.obj == rhs.obj end -local function xfunctor(func, obj) - return setmetatable({func = func, obj = obj}, _xpcall) +local function xfunctor(func, obj) + return setmetatable({ func = func, obj = obj }, _xpcall) end local _pcall = {} _pcall.__call = function(self, ...) if nil == self.obj then - return pcall(self.func, ...) - else - return pcall(self.func, self.obj, ...) - end + return pcall(self.func, ...) + else + return pcall(self.func, self.obj, ...) + end end _pcall.__eq = function(lhs, rhs) return lhs.func == rhs.func and lhs.obj == rhs.obj end -local function functor(func, obj) - return setmetatable({func = func, obj = obj}, _pcall) +local function functor(func, obj) + return setmetatable({ func = func, obj = obj }, _pcall) end local _event = {} @@ -68,62 +68,62 @@ _event.__index = _event --废弃 function _event:Add(func, obj) - assert(func) + assert(func) - if self.keepSafe then + if self.keepSafe then func = xfunctor(func, obj) else func = functor(func, obj) - end + end if self.lock then - local node = {value = func, _prev = 0, _next = 0, removed = true} - table.insert(self.opList, function() self.list:pushnode(node) end) + local node = { value = func, _prev = 0, _next = 0, removed = true } + table.insert(self.opList, function() self.list:pushnode(node) end) return node else return self.list:push(func) - end + end end --废弃 -function _event:Remove(func, obj) - for i, v in ilist(self.list) do +function _event:Remove(func, obj) + for i, v in ilist(self.list) do if v.func == func and v.obj == obj then if self.lock then - table.insert(self.opList, function() self.list:remove(i) end) + table.insert(self.opList, function() self.list:remove(i) end) else self.list:remove(i) end break end - end + end end function _event:CreateListener(func, obj) - if self.keepSafe then + if self.keepSafe then func = xfunctor(func, obj) else func = functor(func, obj) - end - - return {value = func, _prev = 0, _next = 0, removed = true} + end + + return { value = func, _prev = 0, _next = 0, removed = true } end -function _event:AddListener(handle) +function _event:AddListener(handle) assert(handle) - if self.lock then - table.insert(self.opList, function() self.list:pushnode(handle) end) + if self.lock then + table.insert(self.opList, function() self.list:pushnode(handle) end) else self.list:pushnode(handle) - end + end end -function _event:RemoveListener(handle) - assert(handle) +function _event:RemoveListener(handle) + assert(handle) - if self.lock then - table.insert(self.opList, function() self.list:remove(handle) end) + if self.lock then + table.insert(self.opList, function() self.list:remove(handle) end) else self.list:remove(handle) end @@ -131,11 +131,11 @@ end function _event:Count() return self.list.length -end +end function _event:Clear() self.list:clear() - self.opList = {} + self.opList = {} self.lock = false self.keepSafe = false self.current = nil @@ -143,40 +143,40 @@ end function _event:Dump() local count = 0 - + for _, v in ilist(self.list) do if v.obj then - print("update function:", v.func, "object name:", v.obj.name) + -- print("update function:", v.func, "object name:", v.obj.name) else - print("update function: ", v.func) + -- print("update function: ", v.func) end - + count = count + 1 end - - print("all function is:", count) + + -- print("all function is:", count) end -_event.__call = function(self, ...) - local _list = self.list +_event.__call = function(self, ...) + local _list = self.list self.lock = true - local ilist = ilist + local ilist = ilist - for i, f in ilist(_list) do - self.current = i + for i, f in ilist(_list) do + self.current = i local flag, msg = f(...) - - if not flag then - _list:remove(i) - self.lock = false - error(msg) + + if not flag then + _list:remove(i) + self.lock = false + error(msg) end - end + end - local opList = self.opList - self.lock = false + local opList = self.opList + self.lock = false - for i, op in ipairs(opList) do + for i, op in ipairs(opList) do op() opList[i] = nil end @@ -184,30 +184,30 @@ end function event(name, safe) safe = safe or false - return setmetatable({name = name, keepSafe = safe, lock = false, opList = {}, list = list:new()}, _event) + return setmetatable({ name = name, keepSafe = safe, lock = false, opList = {}, list = list:new() }, _event) end -UpdateBeat = event("Update", true) -LateUpdateBeat = event("LateUpdate", true) -FixedUpdateBeat = event("FixedUpdate", true) -CoUpdateBeat = event("CoUpdate") --只在协同使用 +UpdateBeat = event("Update", true) +LateUpdateBeat = event("LateUpdate", true) +FixedUpdateBeat = event("FixedUpdate", true) +CoUpdateBeat = event("CoUpdate") --只在协同使用 -local Time = Time -local UpdateBeat = UpdateBeat -local LateUpdateBeat = LateUpdateBeat +local Time = Time +local UpdateBeat = UpdateBeat +local LateUpdateBeat = LateUpdateBeat local FixedUpdateBeat = FixedUpdateBeat -local CoUpdateBeat = CoUpdateBeat +local CoUpdateBeat = CoUpdateBeat --逻辑update function Update(deltaTime, unscaledDeltaTime) - Time:SetDeltaTime(deltaTime, unscaledDeltaTime) - UpdateBeat() + Time:SetDeltaTime(deltaTime, unscaledDeltaTime) + UpdateBeat() end -function LateUpdate() - LateUpdateBeat() - CoUpdateBeat() - Time:SetFrameCount() +function LateUpdate() + LateUpdateBeat() + CoUpdateBeat() + Time:SetFrameCount() end --物理update @@ -219,4 +219,4 @@ end function PrintEvents() UpdateBeat:Dump() FixedUpdateBeat:Dump() -end \ No newline at end of file +end diff --git a/lua_probject/tolua_project/jit/bc.lua b/lua_probject/tolua_project/jit/bc.lua index 193cf01f..104a55aa 100644 --- a/lua_probject/tolua_project/jit/bc.lua +++ b/lua_probject/tolua_project/jit/bc.lua @@ -11,7 +11,7 @@ -- -- Example usage: -- --- luajit -jbc -e 'local x=0; for i=1,1e6 do x=x+i end; print(x)' +-- luajit -jbc -e 'local x=0; for i=1,1e6 do x=x+i end; -- print(x)' -- luajit -jbc=- foo.lua -- luajit -jbc=foo.list foo.lua -- @@ -24,10 +24,10 @@ -- -- local bc = require("jit.bc") -- --- local function foo() print("hello") end +-- local function foo() -- print("hello") end -- -- bc.dump(foo) --> -- BYTECODE -- [...] --- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" +-- -- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" -- -- local out = { -- -- Do something with each line: @@ -55,10 +55,14 @@ local stdout, stderr = io.stdout, io.stderr ------------------------------------------------------------------------------ local function ctlsub(c) - if c == "\n" then return "\\n" - elseif c == "\r" then return "\\r" - elseif c == "\t" then return "\\t" - else return format("\\%03d", byte(c)) + if c == "\n" then + return "\\n" + elseif c == "\r" then + return "\\r" + elseif c == "\t" then + return "\\t" + else + return format("\\%03d", byte(c)) end end @@ -66,41 +70,41 @@ end local function bcline(func, pc, prefix) local ins, m = funcbc(func, pc) if not ins then return end - local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) + local ma, mb, mc = band(m, 7), band(m, 15 * 8), band(m, 15 * 128) local a = band(shr(ins, 8), 0xff) - local oidx = 6*band(ins, 0xff) - local op = sub(bcnames, oidx+1, oidx+6) + local oidx = 6 * band(ins, 0xff) + local op = sub(bcnames, oidx + 1, oidx + 6) local s = format("%04d %s %-6s %3s ", pc, prefix or " ", op, ma == 0 and "" or a) local d = shr(ins, 16) - if mc == 13*128 then -- BCMjump - return format("%s=> %04d\n", s, pc+d-0x7fff) + if mc == 13 * 128 then -- BCMjump + return format("%s=> %04d\n", s, pc + d - 0x7fff) end if mb ~= 0 then d = band(d, 0xff) elseif mc == 0 then - return s.."\n" + return s .. "\n" end local kc - if mc == 10*128 then -- BCMstr - kc = funck(func, -d-1) + if mc == 10 * 128 then -- BCMstr + kc = funck(func, -d - 1) kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) - elseif mc == 9*128 then -- BCMnum + elseif mc == 9 * 128 then -- BCMnum kc = funck(func, d) - if op == "TSETM " then kc = kc - 2^52 end - elseif mc == 12*128 then -- BCMfunc - local fi = funcinfo(funck(func, -d-1)) + if op == "TSETM " then kc = kc - 2 ^ 52 end + elseif mc == 12 * 128 then -- BCMfunc + local fi = funcinfo(funck(func, -d - 1)) if fi.ffid then kc = vmdef.ffnames[fi.ffid] else kc = fi.loc end - elseif mc == 5*128 then -- BCMuv + elseif mc == 5 * 128 then -- BCMuv kc = funcuvname(func, d) end if ma == 5 then -- BCMuv local ka = funcuvname(func, a) - if kc then kc = ka.." ; "..kc else kc = ka end + if kc then kc = ka .. " ; " .. kc else kc = ka end end if mb ~= 0 then local b = shr(ins, 24) @@ -108,17 +112,17 @@ local function bcline(func, pc, prefix) return format("%s%3d %3d\n", s, b, d) end if kc then return format("%s%3d ; %s\n", s, d, kc) end - if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits + if mc == 7 * 128 and d > 32767 then d = d - 65536 end -- BCMlits return format("%s%3d\n", s, d) end -- Collect branch targets of a function. local function bctargets(func) local target = {} - for pc=1,1000000000 do + for pc = 1, 1000000000 do local ins, m = funcbc(func, pc) if not ins then break end - if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end + if band(m, 15 * 128) == 13 * 128 then target[pc + shr(ins, 16) - 0x7fff] = true end end return target end @@ -128,7 +132,7 @@ local function bcdump(func, out, all) if not out then out = stdout end local fi = funcinfo(func) if all and fi.children then - for n=-1,-1000000000,-1 do + for n = -1, -1000000000, -1 do local k = funck(func, n) if not k then break end if type(k) == "proto" then bcdump(k, out, true) end @@ -136,7 +140,7 @@ local function bcdump(func, out, all) end out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined)) local target = bctargets(func) - for pc=1,1000000000 do + for pc = 1, 1000000000 do local s = bcline(func, pc, target[pc] and "=>") if not s then break end out:write(s) @@ -187,4 +191,3 @@ return { off = bclistoff, start = bcliston -- For -j command line option. } - diff --git a/lua_probject/tolua_project/jit/dump.lua b/lua_probject/tolua_project/jit/dump.lua index 2bea652b..91e14e3f 100644 --- a/lua_probject/tolua_project/jit/dump.lua +++ b/lua_probject/tolua_project/jit/dump.lua @@ -10,7 +10,7 @@ -- -- Example usage: -- --- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; print(x)" +-- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; -- print(x)" -- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R -- luajit -jdump=is myapp.lua | less -R -- luajit -jdump=-b myapp.lua @@ -28,15 +28,15 @@ -- -- The following dump features are available (* marks the default): -- --- * t Print a line for each started, ended or aborted trace (see also -jv). +-- * t -- print a line for each started, ended or aborted trace (see also -jv). -- * b Dump the traced bytecode. -- * i Dump the IR (intermediate representation). -- r Augment the IR with register/stack slots. -- s Dump the snapshot map. -- * m Dump the generated machine code. --- x Print each taken trace exit. --- X Print each taken trace exit and the contents of all registers. --- a Print the IR of aborted traces, too. +-- x -- print each taken trace exit. +-- X -- print each taken trace exit and the contents of all registers. +-- a -- print the IR of aborted traces, too. -- -- The output format can be set with the following characters: -- @@ -89,9 +89,9 @@ local function fillsymtab_tr(tr, nexit) t[traceexitstub(tr, 0)] = "exit" return end - for i=0,nexit-1 do + for i = 0, nexit - 1 do local addr = traceexitstub(tr, i) - if addr < 0 then addr = addr + 2^32 end + if addr < 0 then addr = addr + 2 ^ 32 end t[addr] = tostring(i) end local addr = traceexitstub(tr, nexit) @@ -103,26 +103,26 @@ local function fillsymtab(tr, nexit) local t = symtab if nexitsym == 0 then local ircall = vmdef.ircall - for i=0,#ircall do + for i = 0, #ircall do local addr = ircalladdr(i) if addr ~= 0 then - if addr < 0 then addr = addr + 2^32 end - t[addr] = ircall[i] + if addr < 0 then addr = addr + 2 ^ 32 end + t[addr] = ircall[i] end end end - if nexitsym == 1000000 then -- Per-trace exit stubs. + if nexitsym == 1000000 then -- Per-trace exit stubs. fillsymtab_tr(tr, nexit) elseif nexit > nexitsym then -- Shared exit stubs. - for i=nexitsym,nexit-1 do + for i = nexitsym, nexit - 1 do local addr = traceexitstub(i) if addr == nil then -- Fall back to per-trace exit stubs. - fillsymtab_tr(tr, nexit) - setmetatable(symtab, symtabmt) - nexit = 1000000 - break + fillsymtab_tr(tr, nexit) + setmetatable(symtab, symtabmt) + nexit = 1000000 + break end - if addr < 0 then addr = addr + 2^32 end + if addr < 0 then addr = addr + 2 ^ 32 end t[addr] = tostring(i) end nexitsym = nexit @@ -140,18 +140,18 @@ local function dump_mcode(tr) if not info then return end local mcode, addr, loop = tracemc(tr) if not mcode then return end - if not disass then disass = require("jit.dis_"..jit.arch) end - if addr < 0 then addr = addr + 2^32 end + if not disass then disass = require("jit.dis_" .. jit.arch) end + if addr < 0 then addr = addr + 2 ^ 32 end out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") local ctx = disass.create(mcode, addr, dumpwrite) ctx.hexdump = 0 ctx.symtab = fillsymtab(tr, info.nexit) if loop ~= 0 then - symtab[addr+loop] = "LOOP" + symtab[addr + loop] = "LOOP" ctx:disass(0, loop) out:write("->LOOP:\n") - ctx:disass(loop, #mcode-loop) - symtab[addr+loop] = nil + ctx:disass(loop, #mcode - loop) + symtab[addr + loop] = nil else ctx:disass(0, #mcode) end @@ -222,8 +222,11 @@ local function colorize_ansi(s, t) end local irtype_ansi = setmetatable({}, - { __index = function(tab, t) - local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; end }) + { + __index = function(tab, t) + local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; + end + }) local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", } @@ -233,8 +236,11 @@ local function colorize_html(s, t) end local irtype_html = setmetatable({}, - { __index = function(tab, t) - local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; end }) + { + __index = function(tab, t) + local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; + end + }) local header_html = [[