diff --git a/lua_probject/extend_project/extend/poker/runfast/CardCheck.lua b/lua_probject/extend_project/extend/poker/runfast/CardCheck.lua index d41e5a95..0115992a 100644 --- a/lua_probject/extend_project/extend/poker/runfast/CardCheck.lua +++ b/lua_probject/extend_project/extend/poker/runfast/CardCheck.lua @@ -10,10 +10,13 @@ local CardCheck = { planelack = false, threelack = false, fourDaiThree = false, - fristCard = true + fristCard = true, + tipCardList = {}, + touchCardSet = {}, + touchCardMao = {} } -local cardType = { +local CardType = { one = 1, long = 2, dui = 3, @@ -27,7 +30,7 @@ local cardType = { local M = CardCheck -function M:initFlag() +function M:InitFlag() local config = DataManager.CurrenRoom.room_config.config self.planeNoBelt = config.planeNoBelt == 1 self.threeNoBelt = config.threeNoBelt == 1 @@ -41,7 +44,7 @@ function M:initFlag() return self end -function M:initLastCard(cardList) +function M:InitLastCard(cardList) self._flag_fristCard = false if #cardList == 0 then self._flag_fristCard = true @@ -50,6 +53,7 @@ function M:initLastCard(cardList) self.lastCardNum = #cardList table.sort(cardList) pt(cardList) + self.lastMinCard = math.floor(cardList[1] / 10) local temp_long = 0 self:Clear() self._flag_allCards = false @@ -153,7 +157,7 @@ function M:initCards(cardList, flag, flag_allCards) end function M:CheckCards() - if self.cardNum ~= 4 and self.cardNum ~= self.self.lastCardNum then + if self.cardNum ~= 4 and self.cardNum ~= self.lastCardNum and not self._flag_fristCard then return end @@ -180,20 +184,163 @@ function M:CheckCards() return false end -function M:CheckAloneOrLong() - if self.cardNum == 1 and M:CheckType(cardType.one) then - return cardType.one +function M:CheckOutCard(cardList) + self.tipCardList = {} + self.touchCardSet = {} + self.touchCardMao = {} + + local cardMap = {} + local cardSet = {} + local cardType,only,longLength = self:CheckOutCardGetType() + + if cardType == 0 then + return end - if self.long and M:CheckType(cardType.long) then - return cardType.long + + for i = 1, #cardList do + local number = math.floor(cardList[i].card_code_number / 10) + if cardMap[number] then + cardMap[number].value = cardMap[number].value + 1 + table.insert(cardMap[number].cardList, cardList[i]) + else + cardMap[number] = {} + cardMap[number].value = 1 + cardMap[number].cardList = {} + table.insert(cardMap[number].cardList, cardList[i]) + table.insert(cardSet, number) + end + end + + table.sort(cardSet) + + local tipCardSet = self:CheckOutCardGetTouchSet(cardSet,cardMap,cardType,longLength) + + self:CheckOutCardSetTipList(tipCardSet,longLength,cardMap,cardType) +end + +function M:CheckOutCardGetType() + local cardType = 0 + local only = 0 + local longLength = 1 + if self.type == CardType.one or self.type == CardType.long then + cardType = 1 + if self.type == CardType.long then + longLength = self.lastCardNum + end + elseif self.type == CardType.dui then + cardType = 2 + if self.lastCardNum > 2 then + longLength = self.lastCardNum/2 + end + elseif self.type == CardType.threeAndTwo or self.type == CardType.onlyThree or self.type == CardType.normolPlant or self.type == CardType.onlyPlant then + cardType = 3 + if self.type == CardType.onlyThree or self.type == CardType.onlyPlant then + only = 1 + if self.type == CardType.onlyPlant then + longLength = self.lastCardNum/3 + end + end + if self.type == CardType.normolPlant then + longLength = self.lastCardNum/5 + end + elseif self.type == CardType.zha or self.type == CardType.zhaAndThreee then + cardType = 4 + if self.type == CardType.zha then + only = 1 + end + end + return cardType,only,longLength +end + +function M:CheckOutCardGetTouchSet(cardSet,cardMap,cardType,longLength) + print("lingmengCheckOutCardGetTouchSet",cardType,longLength,self.lastMinCard) + pt(cardSet) + pt(cardMap) + local tempLong = 0 + local lastCard = 0 + local tempCardSet = {} + local tipCardSet = {} + for i = 1, #cardSet do + local card = cardSet[i] + if (cardMap[card].value >= cardType or cardMap[card].value == 4) and card > self.lastMinCard then + if tempLong == 0 then + tempLong = 1 + else + if lastCard - card == -1 then + tempLong = tempLong + 1 + else + if tempLong >= longLength then + for j = 1,tempLong do + table.insert(self.touchCardSet,tempCardSet[j]) + self.touchCardMao[tempCardSet[j]] = 1 + end + end + table.insert(tipCardSet,tempCardSet) + tempLong = 1 + tempCardSet = {} + end + end + table.insert(tempCardSet,card) + lastCard = card + end + end + if tempLong >= longLength then + for j = 1,tempLong do + table.insert(self.touchCardSet,tempCardSet[j]) + self.touchCardMao[tempCardSet[j]] = 1 + end + end + table.insert(tipCardSet,tempCardSet) + return tipCardSet +end + +function M:CheckOutCardSetTipList(tipCardSet,longLength,cardMap,cardType) + print("lingmengCheckOutCardSetTipList",longLength,cardMap,cardType) + pt(tipCardSet) + for i = 1, #tipCardSet do + local tipCardSetLen = #tipCardSet[i] + if tipCardSetLen == longLength then + local tempList = {} + for j = 1, tipCardSetLen do + local card = tipCardSet[i][j] + local minNum = Mathf.Min(cardMap[card].value,cardType) + for k = 1 , minNum do + table.insert(tempList,cardMap[card].cardList[k]) + end + end + table.insert(self.tipCardList,tempList) + else + for j = 1, tipCardSetLen do + if j + longLength <= tipCardSetLen then + local tempList = {} + for k = j,j + longLength do + local card = tipCardSet[i][k] + local minNum = Mathf.Min(cardMap[card].value,cardType) + for l = 1 , minNum do + table.insert(tempList,cardMap[card].cardList[l]) + end + end + table.insert(self.tipCardList,tempList) + end + end + end + end +end + +function M:CheckAloneOrLong() + if self.cardNum == 1 and M:CheckType(CardType.one) then + return CardType.one + end + if self.long and M:CheckType(CardType.long) then + return CardType.long end end function M:CheckDuiZi() - if self.cardNum == 2 and self.cardSize == 1 and M:CheckType(cardType.dui) then - return cardType.dui + if self.cardNum == 2 and self.cardSize == 1 and M:CheckType(CardType.dui) then + return CardType.dui end - if self.cardNum % 2 == 0 and M:CheckType(cardType.dui) then + if self.cardNum % 2 == 0 and M:CheckType(CardType.dui) then local last_k for i = 1, self.cardSize do local k = self.cardListSord[i] @@ -211,28 +358,28 @@ function M:CheckDuiZi() return end end - return cardType.dui + return CardType.dui end end function M:CheckSanDai() --三张 - if self.cardNum == 5 and M:CheckType(cardType.threeAndTwo) then + if self.cardNum == 5 and M:CheckType(CardType.threeAndTwo) then for i = 1, self.cardSize do local k = self.cardListSord[i] local v = self.cardList[k] if v >= 3 then - return cardType.threeAndTwo + return CardType.threeAndTwo end end end - if self.threelack and self.cardNum == 4 and self.cardSize == 2 and self._flag_allCards and M:CheckType(cardType.threeAndTwo) then - return cardType.threeAndTwo + if self.threelack and self.cardNum == 4 and self.cardSize == 2 and self._flag_allCards and M:CheckType(CardType.threeAndTwo) then + return CardType.threeAndTwo end - if self.threeNoBelt and self.cardNum == 3 and self.cardSize == 1 and M:CheckType(cardType.onlyThree) then - return cardType.onlyThree + if self.threeNoBelt and self.cardNum == 3 and self.cardSize == 1 and M:CheckType(CardType.onlyThree) then + return CardType.onlyThree end @@ -242,7 +389,7 @@ function M:CheckSanDai() temp_normol_feiji = self.cardNum / 5 end - if temp_normol_feiji and M:CheckType(cardType.normolPlant) then + if temp_normol_feiji and M:CheckType(CardType.normolPlant) then local last_k local num_san = 0 for i = 1, self.cardSize do @@ -261,7 +408,7 @@ function M:CheckSanDai() end end if num_san >= temp_normol_feiji then - return cardType.normolPlant + return CardType.normolPlant else return end @@ -269,7 +416,7 @@ function M:CheckSanDai() print("liengmengCheckthreelack", self.threelack, self._flag_allCards) - if self.threelack and self._flag_allCards and M:CheckType(cardType.normolPlant) then + if self.threelack and self._flag_allCards and M:CheckType(CardType.normolPlant) then local last_k local num_san = 0 for k, v in pairs(self.cardList) do @@ -290,7 +437,7 @@ function M:CheckSanDai() print("liengmengCheckthreelack4", num_san, self.cardNum - num_san * 3 < num_san * 2) if self.cardNum - num_san * 3 < num_san * 2 then - return cardType.normolPlant + return CardType.normolPlant else return end @@ -298,7 +445,7 @@ function M:CheckSanDai() print("liengmengCheckplaneNoBelt", self.planeNoBelt, self.cardNum % 3) - if self.planeNoBelt and self.cardNum % 3 == 0 and M:CheckType(cardType.onlyPlant) then + if self.planeNoBelt and self.cardNum % 3 == 0 and M:CheckType(CardType.onlyPlant) then local last_k for i = 1, self.cardSize do local k = self.cardListSord[i] @@ -316,16 +463,16 @@ function M:CheckSanDai() return end end - return cardType.onlyPlant + return CardType.onlyPlant end end function M:CheckZha() if self.cardNum == 4 and self.cardSize == 1 then - return cardType.zha + return CardType.zha end - if self.fourDaiThree and self.cardNum == 7 and M:CheckType(cardType.zhaAndThreee) then + if self.fourDaiThree and self.cardNum == 7 and M:CheckType(CardType.zhaAndThreee) then local flag_four for i = 1, self.cardSize do local k = self.cardListSord[i] @@ -334,7 +481,7 @@ function M:CheckZha() return true end end - return cardType.zhaAndThreee + return CardType.zhaAndThreee end end @@ -342,6 +489,18 @@ function M:CheckType(type) return self._flag_checkLst or self._flag_fristCard or type == self.type end +function M:GetTipsList() + return self.tipCardList +end + +function M:GetTouchSet() + return self.touchCardSet +end + +function M:GetTouchCardMap() + return self.touchCardMao +end + function M:Clear() self.cardList = {} self.cardListSord = {} 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 13d6d87c..972d4cae 100644 --- a/lua_probject/extend_project/extend/poker/runfast/RunFast_MainView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/RunFast_MainView.lua @@ -790,8 +790,10 @@ function M:EventInit() m = true end local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]._cardCheck:initLastCard(lastCardList) - self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) + -- self._player_card_info[1]._cardCheck:InitLastCard(lastCardList) + -- self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) + card_info:ShowOutCardOption2(lastCardList,ctr_number,m) + end) -- 托管 _gamectr:AddEventListener(RunFast_GameEvent.Game_TuoGuan, function(...) 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 701f9dde..8afaf829 100644 --- a/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua @@ -85,7 +85,7 @@ function M:init() self._view_handCard = self._view:GetChild('List_HandCard') self._view_Out = self._view:GetChild('List_Out') - self._cardCheck = RunFast_CardCheck:initFlag() + self._cardCheck = RunFast_CardCheck:InitFlag() -------------------------------------------------------------- end @@ -778,6 +778,28 @@ function M:HidePiao() self.ctr_piao.selectedIndex = 0 end +function M:ShowOutCardOption2(lastCardList,ctr_select,mustPutMaxCard) + self._cardCheck:InitLastCard(lastCardList) + self._cardCheck:CheckOutCard(self.card_list) + self.tips_card_list = self._cardCheck:GetTipsList() + self.touchCardSet = self._cardCheck:GetTouchSet() + self.touchCardMap = self._cardCheck:GetTouchCardMap() + + print("lingmengShowOutCardOption2",#self.touchCardSet ) + pt( self.touchCardSet ) + pt(self.touchCardMap) + if #self.touchCardSet >= 1 then + -- body --在这个方法里添加判断抬起牌是否符合出牌类型(少跑一次手牌循环) + self:UpdateHandCardsColor() + end + + if #self.tips_card_list == 1 then + self:ShowTipsCard(1) + end + + self.ctr_put_card_option.selectedIndex = ctr_select +end + function M:ShowOutCardOption(ctr_select, type, number, length, mustPutMaxCard, play, zdts) --for i = 1, #self.out_card_list do -- local card = self.out_card_list[i] @@ -1031,12 +1053,36 @@ function M:UpdateCardMove(btn_card, isSelected, isPlay) end -- +-- function M:UpdateHandCardsColor() +-- local send_card = {} +-- for i = 1, #self.card_list do +-- local card_view = self.card_list[i] +-- local num = card_view.btn_card.touchable == true and 0 or 1 +-- self:SetBtnCardColor(card_view, num) +-- if card_view.btn_card.selected and card_view.btn_card.touchable then +-- table.insert(send_card, card_view) +-- end +-- end +-- if #send_card > 0 then +-- table.sort(send_card, tableSortNumber) +-- self._cardCheck:initCards(send_card, false, #send_card == self._view_handCard.numItems) +-- self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 +-- else +-- self._ctr_canSendCard.selectedIndex = 0 +-- end +-- end + function M:UpdateHandCardsColor() local send_card = {} for i = 1, #self.card_list do local card_view = self.card_list[i] - local num = card_view.btn_card.touchable == true and 0 or 1 - self:SetBtnCardColor(card_view, num) + if self.touchCardMap[math.floor(card_view.card_code_number / 10)] then + card_view.btn_card.touchable = true + self:SetBtnCardColor(card_view, 0) + else + card_view.btn_card.touchable = false + self:SetBtnCardColor(card_view, 1) + end if card_view.btn_card.selected and card_view.btn_card.touchable then table.insert(send_card, card_view) end @@ -1142,7 +1188,7 @@ function M:ShowTipsCard(index) end end pt(item) - self._cardCheck:initCards(item) + self._cardCheck:InitFlag(item) self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 end