local M = {} -- 检测牌是否存在 function M:checkCard(eventCard, cardList, num) if num == nil then num = 1 end local result = 0 for i = 1, #cardList do if (cardList[i] == eventCard) then result = result + 1 if (result == num) then return true end end end return false end -- 获取列表中牌数量 function M:cardNum(eventCard, cardList) local result = 0 if cardList == nil then return result end for i = 1, #cardList do local card = cardList[i] if (card == eventCard) then result = result + 1 end end return result end --麻雀转弯 function M:tryShunzi1(list, index_x) if self.pair_count > 0 then return false end if list[1] < 300 and list[1] % 100 > 8 then return false end return false end function M:tryPair(list,index_x) --对子(麻雀) if DataManager.CurrenRoom == nil then return false end local player = DataManager.CurrenRoom.self_player if player == nil then return false end if self.pair_count > 0 then return false end local cardInhand = player.handcard_list if (self:checkCard(list[1] + 1,list) and self:checkCard(list[1] + 2, list)) then local _huxi = 0 if self:checkCard(list[1], cardInhand, 3) then --是顺子并且还有对子 if list[1] % 100 == 2 or list[1] % 100 == 7 or list[1] == 210 or list[1] == 110 then _huxi = 3 else _huxi = 2 end if _huxi == 0 then return false end return _huxi end if self:checkCard(list[2], cardInhand, 3) then --是顺子并且还有对子 if list[2] % 100 == 2 or list[2] % 100 == 7 or list[2] == 210 or list[2] == 110 then _huxi = 3 else _huxi = 2 end if _huxi == 0 then return false end return _huxi end if self:checkCard(list[3], cardInhand, 3) then --是顺子并且还有对子 if list[3] % 100 == 2 or list[3] % 100 == 7 or list[3] == 210 or list[3] == 110 then _huxi = 3 else _huxi = 2 end if _huxi == 0 then return false end return _huxi end end return false end function M:tryPair1(list) --对子(麻雀) if self.pair_count > 0 then return false end if list ~= nil and #list > 1 and #list < 3 and self:checkCard(list[1], list, 2) then local _huxi = 0 if list[1] % 100 == 2 or list[1] % 100 == 7 or list[1] == 210 or list[1] == 110 then _huxi = 2 end if _huxi == 0 then return false end return _huxi end return false end --坎 function M:tryKezi(list) if (self:checkCard(list[1], list, 3)) then local _huxi = 0 if list[1] % 100 == 2 or list[1] % 100 == 7 or list[1] == 210 or list[1] == 110 then _huxi = 4 else _huxi = 3 end return _huxi end return false end --团圆 function M:tryKezi1(list) if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return false end local player = DataManager.CurrenRoom.self_player if player == nil or list == nil then return false end local huxi = self:GetFzTYData(list[1], player, list) -- print(huxi) if huxi ~= false then return huxi end return false end function M:GetFzTYData(card, player, cardlist) local huxi = 0 local fzNum = 0 local ctype = 1 if player.fz_list ~= nil and #player.fz_list > 0 then for k = 1, #player.fz_list do local opcard_list = player.fz_list[k].opcard if opcard_list ~= nil and #opcard_list > 0 then for i = 1, #opcard_list do if opcard_list[i] == card then fzNum = fzNum + 1 ctype = player.fz_list[k].type end end end end end fzNum = fzNum + self:cardNum(card, player.handcard_list) -- print(fzNum,card,self:cardNum(card, player.handcard_list)) if fzNum == 4 then --团圆 if ((ctype == 4 or ctype == 2) and self:checkCard(card, cardlist, 1)) or checkCard(card, self.cardList, 4) then --暗团圆 if card % 100 == 2 or card % 100 == 7 or card == 110 or card == 210 then huxi = 8 return huxi else huxi = 6 return huxi end else if card % 100 == 2 or card % 100 == 7 or card == 110 or card == 210 then --明团圆 huxi = 7 return huxi else huxi = 5 return huxi end end end return false end function M:checkXi(lists) local handHuXi = 0 self.pair_count = 0 for i = 1, #lists do if self:tryKezi(lists[i]) ~= false then handHuXi = handHuXi + self:tryKezi(lists[i]) end -- if self:tryKezi1(lists[i]) ~= false then -- handHuXi = handHuXi + self:tryKezi1(lists[i]) -- end if self:tryPair(lists[i],index_x) ~= false then handHuXi = handHuXi + self:tryPair(lists[i],index_x) self.pair_count = 1 end end for i = 1, #lists do if self:tryPair1(lists[i]) ~= false then handHuXi = handHuXi + self:tryPair1(lists[i]) self.pair_count = 1 end end -- print(handHuXi) return handHuXi end function M.getHuxi(list,index_x) if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local self = setmetatable({}, {__index = M}) return self:checkXi(list,index_x) end return M