From 69f358c85c8128d2ab72bb076cab4dc9834e5313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=AE=B6=E7=82=9C?= <2029049582@qq.com> Date: Thu, 10 Apr 2025 12:25:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AC=E6=8F=90=E7=A4=BA=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extend/majiang/chaozhougui/CardCheck.lua | 188 ++++++++-------- .../extend/majiang/lichuan/CardCheck.lua | 203 +++++++++--------- .../extend/majiang/lichuan/EXMainView.lua | 19 +- .../lichuan/MJPlayerSelfCardInfoView.lua | 108 +++++----- 4 files changed, 261 insertions(+), 257 deletions(-) diff --git a/lua_probject/extend_project/extend/majiang/chaozhougui/CardCheck.lua b/lua_probject/extend_project/extend/majiang/chaozhougui/CardCheck.lua index 71dd7f8e..a1b7396b 100644 --- a/lua_probject/extend_project/extend/majiang/chaozhougui/CardCheck.lua +++ b/lua_probject/extend_project/extend/majiang/chaozhougui/CardCheck.lua @@ -1,11 +1,11 @@ -- 检测牌是否存在 -local function checkCard(eventCard,cardList,num) +local function checkCard(eventCard, cardList, num) num = num == nil and 1 or num local result = 0 - for i = 1,#cardList do + for i = 1, #cardList do if (cardList[i] == eventCard) then result = result + 1 - if(result ==num) then + if (result == num) then return true end end @@ -14,24 +14,24 @@ local function checkCard(eventCard,cardList,num) end -- 移除指定数量的牌 -local function removeCard(cardList, card,count) - for i=1,count do - list_remove(cardList,card) +local function removeCard(cardList, card, count) + for i = 1, count do + list_remove(cardList, card) end end -local function checkCardAndRomve(eventCard,cardList,num) - if(checkCard(eventCard,cardList,num)) then - removeCard(cardList,eventCard,num) +local function checkCardAndRomve(eventCard, cardList, num) + if (checkCard(eventCard, cardList, num)) then + removeCard(cardList, eventCard, num) return true end return false end -- 获取列表中牌数量 -local function cardNum(eventCard,cardList) +local function cardNum(eventCard, cardList) local result = 0 - for i=1,#cardList do + for i = 1, #cardList do local card = cardList[i] if (card == eventCard) then result = result + 1 @@ -40,7 +40,7 @@ local function cardNum(eventCard,cardList) return result end -local zhongid = 0 +local zhongid = 0 local M = { @@ -54,16 +54,16 @@ local M = { } -function M:push(cardGroup) - self.stack[#self.stack+1] = cardGroup +function M:push(cardGroup) + self.stack[#self.stack + 1] = cardGroup end function M:rollBack() local cardGroup = self.stack[#self.stack] - table.remove(self.stack,#self.stack) - for _,card in ipairs(cardGroup) do + table.remove(self.stack, #self.stack) + for _, card in ipairs(cardGroup) do if (card == zhongid) then - self.zhong_count = self.zhong_count +1 + self.zhong_count = self.zhong_count + 1 else self.cardList[#self.cardList + 1] = card end @@ -71,36 +71,36 @@ function M:rollBack() table.sort(self.cardList) end -function M:tryShunzi(card) - if (card < 400 and card % 100 > 7) then +function M:tryShunzi(card) + if (card < 400 and card % 100 > 7) then return false end - if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then + if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 1, 1) removeCard(self.cardList, card + 2, 1) - local cardGroup = {card,card+1,card+2} + local cardGroup = { card, card + 1, card + 2 } self:push(cardGroup) return true end return false end -function M:tryKezi(card) +function M:tryKezi(card) if (checkCardAndRomve(card, self.cardList, 3)) then - local cardGroup = {card,card,card} + local cardGroup = { card, card, card } self:push(cardGroup) return true end return false end -function M:tryPair(card) +function M:tryPair(card) if (self.pair_count > 0) then return false end if (checkCardAndRomve(card, self.cardList, 2)) then - local cardGroup = {card,card} + local cardGroup = { card, card } self:push(cardGroup) self.pair_count = 1 return true @@ -108,28 +108,27 @@ function M:tryPair(card) return false end - -function M:tryKezi1Zhong(card) - if (self.zhong_count >= 1 and checkCardAndRomve(card, self.cardList,2)) then - local cardGroup = {card,card,zhongid} +function M:tryKezi1Zhong(card) + if (self.zhong_count >= 1 and checkCardAndRomve(card, self.cardList, 2)) then + local cardGroup = { card, card, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -1 - return true - end - return false -end - -function M:tryKezi2Zhong(card) - if (self.zhong_count >= 2 and checkCardAndRomve(card, self.cardList,1)) then - local cardGroup = {card,zhongid,zhongid} - self:push(cardGroup) - self.zhong_count = self.zhong_count -2 + self.zhong_count = self.zhong_count - 1 return true end return false end -function M:tryShunzi1Zhong(card) +function M:tryKezi2Zhong(card) + if (self.zhong_count >= 2 and checkCardAndRomve(card, self.cardList, 1)) then + local cardGroup = { card, zhongid, zhongid } + self:push(cardGroup) + self.zhong_count = self.zhong_count - 2 + return true + end + return false +end + +function M:tryShunzi1Zhong(card) if (card % 100 > 8) then return false end @@ -141,8 +140,8 @@ function M:tryShunzi1Zhong(card) if (checkCard(card + 1, self.cardList)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 1, 1) - self.zhong_count = self.zhong_count -1 - local cardGroup = {card,card+1,zhongid} + self.zhong_count = self.zhong_count - 1 + local cardGroup = { card, card + 1, zhongid } self:push(cardGroup) return true end @@ -150,15 +149,15 @@ function M:tryShunzi1Zhong(card) if (checkCard(card + 2, self.cardList) and ((card + 1) % 100 ~= 0)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 2, 1) - self.zhong_count = self.zhong_count -1 - local cardGroup = {card,zhongid,card+2} + self.zhong_count = self.zhong_count - 1 + local cardGroup = { card, zhongid, card + 2 } self:push(cardGroup) return true end return false end -function M:tryPair1Zhong(card) +function M:tryPair1Zhong(card) if (self.pair_count > 0) then return false end @@ -166,28 +165,28 @@ function M:tryPair1Zhong(card) return false end removeCard(self.cardList, card, 1) - local cardGroup = {card,zhongid} + local cardGroup = { card, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -1 + self.zhong_count = self.zhong_count - 1 self.pair_count = 1 return true end -function M:tryPair2Zhong() +function M:tryPair2Zhong() if (self.pair_count > 0) then return false end if (self.zhong_count < 2) then return false end - local cardGroup = {zhongid,zhongid} + local cardGroup = { zhongid, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -2 + self.zhong_count = self.zhong_count - 2 self.pair_count = 1 return true end -function M:tryWin() +function M:tryWin() if (self.zhong_count == 4 and not self.eight_laizi) or (self.zhong_count == 8 and self.eight_laizi) then return true end @@ -233,7 +232,6 @@ function M:tryWin() end if (self:tryKezi2Zhong(activeCard)) then - if (self:tryWin()) then return true end @@ -257,7 +255,7 @@ function M:tryWin() return false end -function M:checkQidui() +function M:checkQidui() if (not self.qidui) then return false end @@ -270,17 +268,17 @@ function M:checkQidui() return self:isQdPari(cardList) end -function M:isQdPari(cardList) - if(self.qidui_pari_count == 7) then +function M:isQdPari(cardList) + if (self.qidui_pari_count == 7) then return true end - if (#cardList== 0) then + if (#cardList == 0) then return true end local card = cardList[1] if (cardNum(card, cardList) >= 2) then removeCard(cardList, card, 2) - self.qidui_pari_count = self.qidui_pari_count +1 + self.qidui_pari_count = self.qidui_pari_count + 1 if (self:isQdPari(cardList)) then return true end @@ -289,7 +287,7 @@ function M:isQdPari(cardList) if (self.hongzhong_count > 0) then removeCard(cardList, card, 1) self.hongzhong_count = self.hongzhong_count - 1 - self.qidui_pari_count = self.qidui_pari_count +1 + self.qidui_pari_count = self.qidui_pari_count + 1 if (self:isQdPari(cardList)) then return true end @@ -297,13 +295,13 @@ function M:isQdPari(cardList) return false end -local function init(self,cardInhand,addCard,isZhong,qidui,eightLaizi) +local function init(self, cardInhand, addCard, isZhong, qidui, eightLaizi) self.stack = {} self.pair_count = 0 self.cardList = membe_clone(cardInhand) self.qidui = qidui self.eight_laizi = eightLaizi - self.cardList[#self.cardList+1] = addCard + self.cardList[#self.cardList + 1] = addCard if (isZhong) then self.zhong_count = cardNum(zhongid, self.cardList) removeCard(self.cardList, zhongid, self.zhong_count) @@ -314,65 +312,63 @@ local function init(self,cardInhand,addCard,isZhong,qidui,eightLaizi) return self:checkQidui() or self:tryWin() end -local specialCardList={400,403,406,409,412,415,418} -function M.tingPai(cardInhand,isZhong,qidui,eightLaizi) +local specialCardList = { 400, 403, 406, 409, 412, 415, 418 } +function M.tingPai(cardInhand, isZhong, qidui, eightLaizi) --printlog("isZhong",isZhong) --printlog("qidui",qidui) --printlog("eightLaizi",eightLaizi) --pt(cardInhand) - local self = setmetatable({}, {__index = M}) + local self = setmetatable({}, { __index = M }) local tingList = {} if not cardInhand or #cardInhand == 0 then return tingList end - for k=100,300,100 do - for i=1,9 do + for k = 100, 300, 100 do + for i = 1, 9 do local tem = k + i - local result = init(self,cardInhand,tem,isZhong,qidui,eightLaizi) + local result = init(self, cardInhand, tem, isZhong, qidui, eightLaizi) --printlog("返回结果为===>>>",result) - if(result) then - tingList[#tingList + 1] = tem + if (result) then + tingList[#tingList + 1] = tem end end end - - for j=1,#specialCardList do + + for j = 1, #specialCardList do local tem = specialCardList[j] - local result = init(self,cardInhand,tem,isZhong,qidui,eightLaizi) - if(result) then - tingList[#tingList + 1] = tem + local result = init(self, cardInhand, tem, isZhong, qidui, eightLaizi) + if (result) then + tingList[#tingList + 1] = tem end end - + return tingList end -function M.MuiltiplteCaculateTingPai(cardInhand,isZhong,qidui,eightLaizi) - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - zhongid=DataManager.CurrenRoom.laiziInfo[1] - local tempTingList2={} - local tempTingList1=M.tingPai(cardInhand,isZhong,qidui,eightLaizi) +function M.MuiltiplteCaculateTingPai(cardInhand, isZhong, qidui, eightLaizi) + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + zhongid = DataManager.CurrenRoom.laiziInfo[1] + local tempTingList2 = {} + local tempTingList1 = M.tingPai(cardInhand, isZhong, qidui, eightLaizi) if DataManager.CurrenRoom.laiziInfo[2] then - zhongid=DataManager.CurrenRoom.laiziInfo[2] - tempTingList2=M.tingPai(cardInhand,isZhong,qidui,eightLaizi) - zhongid=DataManager.CurrenRoom.laiziInfo[1] + zhongid = DataManager.CurrenRoom.laiziInfo[2] + tempTingList2 = M.tingPai(cardInhand, isZhong, qidui, eightLaizi) + zhongid = DataManager.CurrenRoom.laiziInfo[1] end - local currentTingList={} - if #tempTingList1>0 and #tempTingList2>0 then - currentTingList=CombineDictionaryAndRemoveSomeItem(tempTingList1,tempTingList2) - elseif #tempTingList1>0 then - currentTingList=tempTingList1 - elseif #tempTingList2>0 then - currentTingList=tempTingList2 + local currentTingList = {} + if #tempTingList1 > 0 and #tempTingList2 > 0 then + currentTingList = CombineDictionaryAndRemoveSomeItem(tempTingList1, tempTingList2) + elseif #tempTingList1 > 0 then + currentTingList = tempTingList1 + elseif #tempTingList2 > 0 then + currentTingList = tempTingList2 end - + return currentTingList - else - zhongid=0 - return M.tingPai(cardInhand,isZhong,qidui,eightLaizi) + zhongid = 0 + return M.tingPai(cardInhand, isZhong, qidui, eightLaizi) end - end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/lichuan/CardCheck.lua b/lua_probject/extend_project/extend/majiang/lichuan/CardCheck.lua index 71dd7f8e..8d69dfc3 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/CardCheck.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/CardCheck.lua @@ -1,11 +1,11 @@ -- 检测牌是否存在 -local function checkCard(eventCard,cardList,num) +local function checkCard(eventCard, cardList, num) num = num == nil and 1 or num local result = 0 - for i = 1,#cardList do + for i = 1, #cardList do if (cardList[i] == eventCard) then result = result + 1 - if(result ==num) then + if (result == num) then return true end end @@ -14,24 +14,24 @@ local function checkCard(eventCard,cardList,num) end -- 移除指定数量的牌 -local function removeCard(cardList, card,count) - for i=1,count do - list_remove(cardList,card) +local function removeCard(cardList, card, count) + for i = 1, count do + list_remove(cardList, card) end end -local function checkCardAndRomve(eventCard,cardList,num) - if(checkCard(eventCard,cardList,num)) then - removeCard(cardList,eventCard,num) +local function checkCardAndRomve(eventCard, cardList, num) + if (checkCard(eventCard, cardList, num)) then + removeCard(cardList, eventCard, num) return true end return false end -- 获取列表中牌数量 -local function cardNum(eventCard,cardList) +local function cardNum(eventCard, cardList) local result = 0 - for i=1,#cardList do + for i = 1, #cardList do local card = cardList[i] if (card == eventCard) then result = result + 1 @@ -40,7 +40,7 @@ local function cardNum(eventCard,cardList) return result end -local zhongid = 0 +local zhongid = 0 local M = { @@ -54,16 +54,16 @@ local M = { } -function M:push(cardGroup) - self.stack[#self.stack+1] = cardGroup +function M:push(cardGroup) + self.stack[#self.stack + 1] = cardGroup end function M:rollBack() local cardGroup = self.stack[#self.stack] - table.remove(self.stack,#self.stack) - for _,card in ipairs(cardGroup) do + table.remove(self.stack, #self.stack) + for _, card in ipairs(cardGroup) do if (card == zhongid) then - self.zhong_count = self.zhong_count +1 + self.zhong_count = self.zhong_count + 1 else self.cardList[#self.cardList + 1] = card end @@ -71,36 +71,36 @@ function M:rollBack() table.sort(self.cardList) end -function M:tryShunzi(card) - if (card < 400 and card % 100 > 7) then +function M:tryShunzi(card) + if (card < 400 and card % 100 > 7) then return false end - if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then + if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 1, 1) removeCard(self.cardList, card + 2, 1) - local cardGroup = {card,card+1,card+2} + local cardGroup = { card, card + 1, card + 2 } self:push(cardGroup) return true end return false end -function M:tryKezi(card) +function M:tryKezi(card) if (checkCardAndRomve(card, self.cardList, 3)) then - local cardGroup = {card,card,card} + local cardGroup = { card, card, card } self:push(cardGroup) return true end return false end -function M:tryPair(card) +function M:tryPair(card) if (self.pair_count > 0) then return false end if (checkCardAndRomve(card, self.cardList, 2)) then - local cardGroup = {card,card} + local cardGroup = { card, card } self:push(cardGroup) self.pair_count = 1 return true @@ -108,28 +108,27 @@ function M:tryPair(card) return false end - -function M:tryKezi1Zhong(card) - if (self.zhong_count >= 1 and checkCardAndRomve(card, self.cardList,2)) then - local cardGroup = {card,card,zhongid} +function M:tryKezi1Zhong(card) + if (self.zhong_count >= 1 and checkCardAndRomve(card, self.cardList, 2)) then + local cardGroup = { card, card, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -1 - return true - end - return false -end - -function M:tryKezi2Zhong(card) - if (self.zhong_count >= 2 and checkCardAndRomve(card, self.cardList,1)) then - local cardGroup = {card,zhongid,zhongid} - self:push(cardGroup) - self.zhong_count = self.zhong_count -2 + self.zhong_count = self.zhong_count - 1 return true end return false end -function M:tryShunzi1Zhong(card) +function M:tryKezi2Zhong(card) + if (self.zhong_count >= 2 and checkCardAndRomve(card, self.cardList, 1)) then + local cardGroup = { card, zhongid, zhongid } + self:push(cardGroup) + self.zhong_count = self.zhong_count - 2 + return true + end + return false +end + +function M:tryShunzi1Zhong(card) if (card % 100 > 8) then return false end @@ -141,8 +140,8 @@ function M:tryShunzi1Zhong(card) if (checkCard(card + 1, self.cardList)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 1, 1) - self.zhong_count = self.zhong_count -1 - local cardGroup = {card,card+1,zhongid} + self.zhong_count = self.zhong_count - 1 + local cardGroup = { card, card + 1, zhongid } self:push(cardGroup) return true end @@ -150,15 +149,15 @@ function M:tryShunzi1Zhong(card) if (checkCard(card + 2, self.cardList) and ((card + 1) % 100 ~= 0)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 2, 1) - self.zhong_count = self.zhong_count -1 - local cardGroup = {card,zhongid,card+2} + self.zhong_count = self.zhong_count - 1 + local cardGroup = { card, zhongid, card + 2 } self:push(cardGroup) return true end return false end -function M:tryPair1Zhong(card) +function M:tryPair1Zhong(card) if (self.pair_count > 0) then return false end @@ -166,28 +165,28 @@ function M:tryPair1Zhong(card) return false end removeCard(self.cardList, card, 1) - local cardGroup = {card,zhongid} + local cardGroup = { card, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -1 + self.zhong_count = self.zhong_count - 1 self.pair_count = 1 return true end -function M:tryPair2Zhong() +function M:tryPair2Zhong() if (self.pair_count > 0) then return false end if (self.zhong_count < 2) then return false end - local cardGroup = {zhongid,zhongid} + local cardGroup = { zhongid, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -2 + self.zhong_count = self.zhong_count - 2 self.pair_count = 1 return true end -function M:tryWin() +function M:tryWin() if (self.zhong_count == 4 and not self.eight_laizi) or (self.zhong_count == 8 and self.eight_laizi) then return true end @@ -204,6 +203,7 @@ function M:tryWin() local activeCard = self.cardList[1] if (self:tryPair(activeCard)) then + print("tryPair") if (self:tryWin()) then return true end @@ -212,6 +212,7 @@ function M:tryWin() end if (self:tryKezi(activeCard)) then + print("tryKezi") if (self:tryWin()) then return true end @@ -219,6 +220,7 @@ function M:tryWin() end if (self:tryShunzi(activeCard)) then + print("tryShunzi") if (self:tryWin()) then return true end @@ -226,6 +228,7 @@ function M:tryWin() end if (self:tryKezi1Zhong(activeCard)) then + print("tryKezi1Zhong") if (self:tryWin()) then return true end @@ -233,7 +236,7 @@ function M:tryWin() end if (self:tryKezi2Zhong(activeCard)) then - + print("tryKezi2Zhong") if (self:tryWin()) then return true end @@ -241,6 +244,7 @@ function M:tryWin() end if (self:tryShunzi1Zhong(activeCard)) then + print("tryShunzi1Zhong") if (self:tryWin()) then return true end @@ -248,6 +252,7 @@ function M:tryWin() end if (self:tryPair1Zhong(activeCard)) then + print("tryPair1Zhong") if (self:tryWin()) then return true end @@ -257,7 +262,7 @@ function M:tryWin() return false end -function M:checkQidui() +function M:checkQidui() if (not self.qidui) then return false end @@ -270,17 +275,17 @@ function M:checkQidui() return self:isQdPari(cardList) end -function M:isQdPari(cardList) - if(self.qidui_pari_count == 7) then +function M:isQdPari(cardList) + if (self.qidui_pari_count == 7) then return true end - if (#cardList== 0) then + if (#cardList == 0) then return true end local card = cardList[1] if (cardNum(card, cardList) >= 2) then removeCard(cardList, card, 2) - self.qidui_pari_count = self.qidui_pari_count +1 + self.qidui_pari_count = self.qidui_pari_count + 1 if (self:isQdPari(cardList)) then return true end @@ -289,7 +294,7 @@ function M:isQdPari(cardList) if (self.hongzhong_count > 0) then removeCard(cardList, card, 1) self.hongzhong_count = self.hongzhong_count - 1 - self.qidui_pari_count = self.qidui_pari_count +1 + self.qidui_pari_count = self.qidui_pari_count + 1 if (self:isQdPari(cardList)) then return true end @@ -297,13 +302,13 @@ function M:isQdPari(cardList) return false end -local function init(self,cardInhand,addCard,isZhong,qidui,eightLaizi) +local function init(self, cardInhand, addCard, isZhong, qidui, eightLaizi) self.stack = {} self.pair_count = 0 self.cardList = membe_clone(cardInhand) self.qidui = qidui self.eight_laizi = eightLaizi - self.cardList[#self.cardList+1] = addCard + self.cardList[#self.cardList + 1] = addCard if (isZhong) then self.zhong_count = cardNum(zhongid, self.cardList) removeCard(self.cardList, zhongid, self.zhong_count) @@ -314,65 +319,63 @@ local function init(self,cardInhand,addCard,isZhong,qidui,eightLaizi) return self:checkQidui() or self:tryWin() end -local specialCardList={400,403,406,409,412,415,418} -function M.tingPai(cardInhand,isZhong,qidui,eightLaizi) - --printlog("isZhong",isZhong) - --printlog("qidui",qidui) - --printlog("eightLaizi",eightLaizi) - --pt(cardInhand) - local self = setmetatable({}, {__index = M}) +local specialCardList = { 401, 402, 403, 404, 405, 406, 407 } +function M.tingPai(cardInhand, isZhong, qidui, eightLaizi) + printlog("isZhong", isZhong) + printlog("qidui", qidui) + printlog("eightLaizi", eightLaizi) + pt(cardInhand) + local self = setmetatable({}, { __index = M }) local tingList = {} if not cardInhand or #cardInhand == 0 then return tingList end - for k=100,300,100 do - for i=1,9 do + for k = 100, 300, 100 do + for i = 1, 9 do local tem = k + i - local result = init(self,cardInhand,tem,isZhong,qidui,eightLaizi) + local result = init(self, cardInhand, tem, isZhong, qidui, eightLaizi) --printlog("返回结果为===>>>",result) - if(result) then - tingList[#tingList + 1] = tem + if (result) then + tingList[#tingList + 1] = tem end end end - - for j=1,#specialCardList do + + for j = 1, #specialCardList do local tem = specialCardList[j] - local result = init(self,cardInhand,tem,isZhong,qidui,eightLaizi) - if(result) then - tingList[#tingList + 1] = tem + local result = init(self, cardInhand, tem, isZhong, qidui, eightLaizi) + if (result) then + tingList[#tingList + 1] = tem end end - + return tingList end -function M.MuiltiplteCaculateTingPai(cardInhand,isZhong,qidui,eightLaizi) - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then - zhongid=DataManager.CurrenRoom.laiziInfo[1] - local tempTingList2={} - local tempTingList1=M.tingPai(cardInhand,isZhong,qidui,eightLaizi) +function M.MuiltiplteCaculateTingPai(cardInhand, isZhong, qidui, eightLaizi) + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + zhongid = DataManager.CurrenRoom.laiziInfo[1] + local tempTingList2 = {} + local tempTingList1 = M.tingPai(cardInhand, isZhong, qidui, eightLaizi) if DataManager.CurrenRoom.laiziInfo[2] then - zhongid=DataManager.CurrenRoom.laiziInfo[2] - tempTingList2=M.tingPai(cardInhand,isZhong,qidui,eightLaizi) - zhongid=DataManager.CurrenRoom.laiziInfo[1] + zhongid = DataManager.CurrenRoom.laiziInfo[2] + tempTingList2 = M.tingPai(cardInhand, isZhong, qidui, eightLaizi) + zhongid = DataManager.CurrenRoom.laiziInfo[1] end - local currentTingList={} - if #tempTingList1>0 and #tempTingList2>0 then - currentTingList=CombineDictionaryAndRemoveSomeItem(tempTingList1,tempTingList2) - elseif #tempTingList1>0 then - currentTingList=tempTingList1 - elseif #tempTingList2>0 then - currentTingList=tempTingList2 + local currentTingList = {} + if #tempTingList1 > 0 and #tempTingList2 > 0 then + currentTingList = CombineDictionaryAndRemoveSomeItem(tempTingList1, tempTingList2) + elseif #tempTingList1 > 0 then + currentTingList = tempTingList1 + elseif #tempTingList2 > 0 then + currentTingList = tempTingList2 end - + return currentTingList - else - zhongid=0 - return M.tingPai(cardInhand,isZhong,qidui,eightLaizi) + zhongid = 0 + return M.tingPai(cardInhand, isZhong, qidui, eightLaizi) end - end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua index 61f2f86a..7806ad4d 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua @@ -38,12 +38,7 @@ function M:InitView(url) self.Laizi2Btn.visible = true self.bugangnum = self._view:GetChild("bugangnum") - print("==================================jing", room.jing) - if room.jing then - self.jing = self._view:GetChild('jing') - print("==================================self.jing", room.jing) - self.jing.visible = true - end + self.jing = self._view:GetChild('jing') self:PlayerChangeLineState() @@ -105,6 +100,17 @@ function M:UpdateRound() self._view:GetChild("tex_round2").text = self._room.room_config.round end +function M:ShowJing() + print("==================================self._room.jing", self._room.jing) + if self._room.jing then + self.jing.icon = 'ui://Main_Majiang/' .. + get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. self._room.jing + self.jing.visible = true + else + self.jing.visible = false + end +end + function M:InitPlayerInfoView() self._player_info = {} local _player_info = self._player_info @@ -159,6 +165,7 @@ function M:EventInit() -- self:ShowHuTip() self:UpdateRound() self._state.selectedIndex = 1 + self:ShowJing() local list = _room.player_list for i = 1, #list do local p = list[i] diff --git a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua index 72d1d092..52e6ff07 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/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,17 @@ 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) + pt(tingList) 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 +36,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 +70,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 +90,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 +107,6 @@ function M:UpdateHandCard(getcard, mp) end self._out_card = false end - end function M:__OnClickHandCard(context) @@ -117,17 +114,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,16 +157,16 @@ 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) 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) @@ -190,6 +187,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 +202,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