diff --git a/lua_probject/extend_project/extend/poker/runfast/CardCheck.lua b/lua_probject/extend_project/extend/poker/runfast/CardCheck.lua new file mode 100644 index 00000000..51c5fcaa --- /dev/null +++ b/lua_probject/extend_project/extend/poker/runfast/CardCheck.lua @@ -0,0 +1,239 @@ +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 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 e65e8660..c9535ecc 100644 --- a/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerSelfPokerInfoView.lua @@ -4,6 +4,7 @@ --- local RunFast_PlayerPokerInfoView = import('.RunFast_PlayerPokerInfoView') local RunFast_CardType = import('.RunFast_CardType') +local RunFast_CardCheck = import(".CardCheck") local CardView = { btn_card = nil, @@ -84,6 +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() -------------------------------------------------------------- end @@ -550,7 +552,9 @@ function M:zhizhanxuanpai() --智障选牌 end end end + return list_ones else + return {} end end @@ -682,6 +686,8 @@ end function M:TouchMoveEnd(context) local send_card = {} + local currentCard = {} + local xuan_card = {} local fristCard = self._view_handCard:GetChildAt(0) local CardWidth = fristCard.width @@ -704,6 +710,7 @@ function M:TouchMoveEnd(context) for k = 1, #self.card_list do local card = self.card_list[k] + table.insert(currentCard, card.card_code_flower) if not card.btn_card.selected then downCards = downCards - 1 end @@ -715,7 +722,7 @@ function M:TouchMoveEnd(context) and card.btn_card.x < max_x then self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - if not card.btn_card.selected then + if card.btn_card.selected then send_card[#send_card + 1] = card end --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") @@ -732,7 +739,14 @@ function M:TouchMoveEnd(context) Stage.inst:ResetInputState() if downCards == 0 then - self:zhizhanxuanpai() + xuan_card = self:zhizhanxuanpai() + end + + if #send_card > 0 then + self._cardCheck:initCards(#xuan_card > 0 and xuan_card or send_card, #xuan_card > 0) + self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 + else + self._ctr_canSendCard.selectedIndex = 0 end end @@ -1027,7 +1041,6 @@ function M:BtnEvent() self.btn_tips = self._view:GetChild('Btn_Tip') -- 覆盖 self.btn_sendCards = self._view:GetChild('Btn_SendCard') self._ctr_canSendCard = self.btn_sendCards:GetController('can') - self._ctr_canSendCard.selectedIndex = 1 self.btn_sendCards.onClick:Set( function() @@ -1050,7 +1063,7 @@ function M:BtnEvent() end if #send_card == 0 then - self:ErrorTip('请选择要出的牌 ') + self:ErrorTip('请选择要出的牌') else self.gameCtr:SendCard(send_card, currentCard) end