local CardCheck = { cardList = {}, cardNum = 0, cardSize = 0, long = false, planeNoBelt = false, threeNoBelt = false, planelack = false, threelack = false, fourDaiThree = false } local M = CardCheck function M:initFlag() local config = DataManager.CurrenRoom.room_config.config self.planeNoBelt = config.planeNoBelt == 1 self.threeNoBelt = config.threeNoBelt == 1 self.planelack = config.planelack == 1 self.threelack = config.threelack == 1 self.fourDaiThree = config.fourDaiThree print("==============================lingmengcheckinitFlag") pt(config) pt(self) return self end function M:initCards(cardList, flag) local temp_long = 0 self:Clear() if flag then for i = 1, #cardList do local number = math.floor(cardList[i][1].card_code_number / 10) if self.cardList[number] then self.cardList[number] = self.cardList[number] + 1 else self.cardList[number] = 1 self.cardSize = self.cardSize + 1 end self.cardNum = self.cardNum + 1 if i == 1 then temp_long = 1 elseif temp_long == i - 1 then if math.abs(math.floor(cardList[i - 1][1].card_code_number / 10) - number) == 1 then temp_long = i end end end else for i = 1, #cardList do local number = math.floor(cardList[i].card_code_number / 10) if self.cardList[number] then self.cardList[number] = self.cardList[number] + 1 else self.cardList[number] = 1 self.cardSize = self.cardSize + 1 end self.cardNum = self.cardNum + 1 if i == 1 then temp_long = 1 elseif temp_long == i - 1 then if math.abs(math.floor(cardList[i - 1].card_code_number / 10) - number) == 1 then temp_long = i end end end end print(self.cardNum, self.cardSize, temp_long) pt(self.cardList) self.long = temp_long == self.cardNum end function M:CheckCards() print("lingmengcheck1") if self:CheckAloneOrLong() then return true end print("lingmengcheck2") if self:CheckDuiZi() then return true end print("lingmengcheck3") if self:CheckSanDai() then return true end print("lingmengcheck4") if self:CheckZha() then return true end print("lingmengcheck5") return false end function M:CheckAloneOrLong() if self.cardNum == 1 or self.long then return true end end function M:CheckDuiZi() if self.cardNum == 2 and self.cardSize == 1 then return true end if self.cardNum % 2 == 0 then local last_k for k, v in pairs(self.cardList) do if v == 2 then if not last_k then last_k = k else if math.abs(last_k - k) ~= 1 then return end end else return end end return true end end function M:CheckSanDai() --三张 if self.cardNum == 5 and self.cardSize < 4 then return true end if self.threeNoBelt and self.cardNum == 3 and self.cardSize == 1 then return true end if self.threelack and self.cardNum == 4 and self.cardSize == 2 then return true end --飞机 local temp_normol_feiji if self.cardNum % 5 == 0 then temp_normol_feiji = self.cardNum / 5 end print("lingmengCheckSanDaiqian", self.cardNum % 5, self.cardNum / 5, temp_normol_feiji) if temp_normol_feiji then local last_k local num_san = 0 for k, v in pairs(self.cardList) do if v >= 3 then num_san = num_san + 1 if not last_k then last_k = k else if math.abs(last_k - k) ~= 1 then return end end end end print("lingmengCheckSanDai", num_san, temp_normol_feiji) if num_san == temp_normol_feiji then return true else return end end if self.planeNoBelt and self.cardNum % 3 == 0 then local last_k for k, v in pairs(self.cardList) do if v == 3 then if not last_k then last_k = k else if math.abs(last_k - k) ~= 1 then return end end else return end end return true end if self.threelack then local last_k local num_san = 0 for k, v in pairs(self.cardList) do if v >= 3 then num_san = num_san + 1 if not last_k then last_k = k else if math.abs(last_k - k) ~= 1 then return end end end end if self.cardNum - num_san * 3 < num_san * 2 then return true else return end end end function M:CheckZha() if self.cardNum == 4 and self.cardSize == 1 then return true end if self.fourDaiThree and self.cardNum == 7 then local flag_four for k, v in pairs(self.cardList) do if v == 4 then return true end end return false end end function M:Clear() self.cardList = {} self.cardNum = 0 self.cardSize = 0 self.long = false self.planeNoBelt = false self.threeNoBelt = false self.planelack = false self.threelack = false self.fourDaiThree = false end return M