听提示列表
parent
dce2f67297
commit
69f358c85c
|
|
@ -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
|
||||
|
|
@ -55,15 +55,15 @@ local M = {
|
|||
|
||||
|
||||
function M:push(cardGroup)
|
||||
self.stack[#self.stack+1] = 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
|
||||
|
|
@ -79,7 +79,7 @@ function M:tryShunzi(card)
|
|||
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
|
||||
|
|
@ -88,7 +88,7 @@ end
|
|||
|
||||
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
|
||||
|
|
@ -100,7 +100,7 @@ function M:tryPair(card)
|
|||
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,22 +108,21 @@ 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}
|
||||
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
|
||||
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}
|
||||
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 - 2
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
|
@ -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,8 +149,8 @@ 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
|
||||
|
|
@ -166,9 +165,9 @@ 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
|
||||
|
|
@ -180,9 +179,9 @@ function M:tryPair2Zhong()
|
|||
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
|
||||
|
|
@ -233,7 +232,6 @@ function M:tryWin()
|
|||
end
|
||||
|
||||
if (self:tryKezi2Zhong(activeCard)) then
|
||||
|
||||
if (self:tryWin()) then
|
||||
return true
|
||||
end
|
||||
|
|
@ -271,16 +269,16 @@ function M:checkQidui()
|
|||
end
|
||||
|
||||
function M:isQdPari(cardList)
|
||||
if(self.qidui_pari_count == 7) then
|
||||
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,32 +312,32 @@ 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
|
||||
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
|
||||
local result = init(self, cardInhand, tem, isZhong, qidui, eightLaizi)
|
||||
if (result) then
|
||||
tingList[#tingList + 1] = tem
|
||||
end
|
||||
end
|
||||
|
|
@ -347,32 +345,30 @@ function M.tingPai(cardInhand,isZhong,qidui,eightLaizi)
|
|||
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
|
||||
|
|
@ -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
|
||||
|
|
@ -55,15 +55,15 @@ local M = {
|
|||
|
||||
|
||||
function M:push(cardGroup)
|
||||
self.stack[#self.stack+1] = 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
|
||||
|
|
@ -79,7 +79,7 @@ function M:tryShunzi(card)
|
|||
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
|
||||
|
|
@ -88,7 +88,7 @@ end
|
|||
|
||||
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
|
||||
|
|
@ -100,7 +100,7 @@ function M:tryPair(card)
|
|||
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,22 +108,21 @@ 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}
|
||||
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
|
||||
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}
|
||||
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 - 2
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
|
@ -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,8 +149,8 @@ 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
|
||||
|
|
@ -166,9 +165,9 @@ 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
|
||||
|
|
@ -180,9 +179,9 @@ function M:tryPair2Zhong()
|
|||
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
|
||||
|
|
@ -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
|
||||
|
|
@ -271,16 +276,16 @@ function M:checkQidui()
|
|||
end
|
||||
|
||||
function M:isQdPari(cardList)
|
||||
if(self.qidui_pari_count == 7) then
|
||||
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,32 +319,32 @@ 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
|
||||
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
|
||||
local result = init(self, cardInhand, tem, isZhong, qidui, eightLaizi)
|
||||
if (result) then
|
||||
tingList[#tingList + 1] = tem
|
||||
end
|
||||
end
|
||||
|
|
@ -347,32 +352,30 @@ function M.tingPai(cardInhand,isZhong,qidui,eightLaizi)
|
|||
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
|
||||
|
|
@ -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: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]
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ 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] )
|
||||
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,29 +36,25 @@ 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 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 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
|
||||
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
|
||||
obj.card:GetController("laizi").selectedIndex = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -109,7 +107,6 @@ function M:UpdateHandCard(getcard, mp)
|
|||
end
|
||||
self._out_card = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function M:__OnClickHandCard(context)
|
||||
|
|
@ -117,7 +114,7 @@ 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
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue