add fangpaofa

master
FPGA 2025-06-05 20:43:57 +08:00
parent d59550da73
commit 75cb16a135
10 changed files with 590 additions and 580 deletions

View File

@ -651,20 +651,30 @@ function M:__FangziTip(tip, _uid,fptype)
local tip_fanpao = false
local tip_id = 0;
local count = #_tlist
local zdhu = false
local fpao = true
for k = 1, #_tlist do
local td = tip.tip_map_type[_tlist[k]][1]
if td.type == 8 then
tip_hu = true
tip_id = td.id
--自动放炮
--[[ if td.weight==7 then
_gamectr:SendAction(tip_id)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
return
end]]
if td.weight==7 then
zdhu = true
end
end
if td.type == 6 and td.weight == 8 then
fpao = false
end
end
if fpao and zdhu then
_gamectr:SendAction(tip_id)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
return
end
for k = 1, #_tlist do

View File

@ -12,15 +12,9 @@ local function checkCard(eventCard, cardList, num)
end
end
end
return false
end
local function cardType(card)
return card/100
end
-- 移除指定数量的牌
local function removeCard(cardList, card, count)
for i = 1, count do
@ -70,43 +64,23 @@ function M:rollBack()
end
table.sort(self.cardList)
end
--坎
function M:tryKezi(card, player)
if cardNum(card, self.cardList)>=3 then
removeCard(self.cardList, card, 3)
local cardGroup = {card, card, card}
self:push(cardGroup)
local _huxi = 1
if self.drawCard~=card then
_huxi = 3
end
self:pushhuxi(_huxi)
return true
end
return false
end
--顺子1
-- 顺子
function M:tryShunzi1(card, player)
if card < 200 and card % 100 > 8 then
if card < 300 and card % 100 > 8 then
return false
end
if (cardNum(card + 1, self.cardList)> 0 and cardNum(card + 2, self.cardList) > 0 ) then
removeCard(self.cardList, card, 1)
if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then
removeCard(self.cardList, card + 1, 1)
removeCard(self.cardList, card + 2, 1)
removeCard(self.cardList, card, 1)
local cardGroup = {card, card + 1, card + 2}
self:push(cardGroup)
local _huxi = 0
if card%100==1 then
if card>200 then
_huxi = 6
else
_huxi = 3
end
if card == 101 then
_huxi = 3
end
if card == 201 then
_huxi = 6
end
self:pushhuxi(_huxi)
return true
@ -114,160 +88,135 @@ function M:tryShunzi1(card, player)
return false
end
--顺子2
function M:tryShunzi2(card, player)
if cardType(card) == 1 then
if cardNum(card+100,self.cardList) >= 1 and cardNum(card,self.cardList)>=2 then
-- 大大小 小小大
function M:tryShunzi2(card)
if card - card % 100 == 100 then
if checkCard(card + 100, self.cardList, 1) and checkCard(card, self.cardList, 2) then
removeCard(self.cardList, card, 2)
removeCard(self.cardList, card + 100, 1)
local cardGroup = {card, card, card+100}
local cardGroup = {card, card, card + 100}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self:pushhuxi(0)
return true
end
if cardNum(card+100,self.cardList)>=2 then
if (checkCard(card + 100, self.cardList, 2)) and (checkCard(card, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card+100, 2)
local cardGroup = {card, card+100, card+100}
removeCard(self.cardList, card + 100, 2)
local cardGroup = {card, card + 100, card + 100}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self:pushhuxi(0)
return true
end
else
if cardNum(card-100,self.cardList) >= 1 and cardNum(card,self.cardList)>=2 then
if (checkCard(card - 100, self.cardList, 1)) and checkCard(card, self.cardList, 2) then
removeCard(self.cardList, card, 2)
removeCard(self.cardList, card - 100, 1)
local cardGroup = {card, card, card-100}
local cardGroup = {card - 100, card, card}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self:pushhuxi(0)
return true
end
if cardNum(card-100,self.cardList)>=2 then
if (checkCard(card - 100, self.cardList, 2)) and checkCard(card, self.cardList, 1) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-100, 2)
local cardGroup = {card, card-100, card-100}
removeCard(self.cardList, card - 100, 2)
local cardGroup = {card, card - 100, card - 100}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self:pushhuxi(0)
return true
end
end
--print(card)
return false
-- body
end
-- 2 7 10
function M:tryShunzi3(card, player)
if card % 100 == 2 then
if cardNum(card + 5, self.cardList)>0 and cardNum(card + 8, self.cardList)>0 then
if (checkCard(card + 5, self.cardList, 1)) and (checkCard(card + 8, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card + 5, 1)
removeCard(self.cardList, card + 8, 1)
local cardGroup = {card, card + 5, card + 8}
self:push(cardGroup)
local _huxi = 1
local _huxi = 0
if card == 102 then
_huxi = 3
elseif card == 202 then
_huxi = 6
end
self:pushhuxi(_huxi)
return true
end
end
return false
end
function M:tryHuazi(card)
end
function M:tryPair(card)
if (self.pair_count > 0) then
return false
end
if cardNum(card, self.cardList)>=2 then
removeCard(self.cardList, card, 2)
local cardGroup = {card, card , card}
-- 坎
function M:tryKezi(card, player)
if (checkCard(card, self.cardList, 3)) then
removeCard(self.cardList, card, 3)
local cardGroup = {card, card, card}
self:push(cardGroup)
self.pair_count = 1;
local _huxi = 0
if card < 200 then
_huxi = 1
else
_huxi = 3
end
self:pushhuxi(_huxi)
return true
end
-- print(card)
return false
end
function M:tryPair(card)
if (self.pair_count > 0) then
return false
end
if (checkCard(card, self.cardList, 2)) then
removeCard(self.cardList, card, 2)
local cardGroup = {card, card}
self:push(cardGroup)
self.pair_count = 1
return true
end
-- print(card)
return false
end
function M:tryWin(player)
--[[ if #self.cardList == 0 then
if (self.pair_count == 1) then
return true
elseif #self.stack>=2 then
local tempPList={}
for i=1,#self.stack do
local card1=self.stack[i][1]
local card2=self.stack[i][2]
table.insert(tempPList,card1)
table.insert(tempPList,card2)
end
if #tempPList~=4 then return false end
table.sort(tempPList)
if tempPList[1]==tempPList[2]+1 and tempPList[2]==tempPList[3]+1 and tempPList[3]==tempPList[4]+1 then
return true
end
end
return false
end
]]
if #self.cardList == 0 then
if (player.tiCount+player.paoCount)>0 then
if self.pair_count ==1 then
if (player.tiCount + player.paoCount + self.kong_count > 0) then
if (self.pair_count == 1) then
return true
end
return false
else
if self.pair_count >0 then
if (self.pair_count > 0) then
return false
end
return true
end
end
local activeCard = 0
for i = 1, #self.cardList do
if (self.cardList[i] == 201 or self.cardList[i] == 202) then
activeCard = self.cardList[i]
break
end
end
if (activeCard == 0) then
activeCard = self.cardList[1]
end
if (activeCard % 100 == 1) then
if self:tryShunzi1(activeCard, player) then
if self:tryShunzi1(activeCard, player) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryKezi(activeCard, player) then
if self:tryWin(player) then
return true
@ -275,28 +224,23 @@ function M:tryWin(player)
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if (player.tiCount + player.paoCount)>0 then
if (player.tiCount + player.paoCount + self.kong_count > 0) then
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
end
if self:tryShunzi2(activeCard, player) then
if self:tryShunzi2(activeCard) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
elseif activeCard % 100 == 2 then
if self:tryShunzi3(activeCard, player) then
if self:tryWin(player) then
return true
@ -304,7 +248,6 @@ function M:tryWin(player)
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryKezi(activeCard, player) then
if self:tryWin(player) then
return true
@ -312,34 +255,29 @@ function M:tryWin(player)
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if (player.tiCount + player.paoCount)>0 then
if player.tiCount + player.paoCount + self.kong_count > 0 then
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
end
if self:tryShunzi1(activeCard, player) then
if self:tryShunzi1(activeCard, player) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryShunzi2(activeCard, player) then
if self:tryShunzi2(activeCard) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
else
if self:tryKezi(activeCard, player) then
if self:tryWin(player) then
@ -348,146 +286,127 @@ function M:tryWin(player)
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if (player.tiCount + player.paoCount)>0 then
if player.tiCount + player.paoCount + self.kong_count > 0 then
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
end
if self:tryShunzi1(activeCard, player) then
if self:tryShunzi2(activeCard) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryShunzi2(activeCard, player) then
if self:tryShunzi1(activeCard, player) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
end
return false
end
local function init(self, player, cardInhand, addCard)
self.stack = {}
self.stackHuxi = {}
self.pair_count = 0
self.kong_count = 0
self.drawCard=0
self.cardList = membe_clone(cardInhand)
if addCard == nil then
self.kong_count = 1
else
self.kong_count = 0
self.cardList[#self.cardList + 1] = addCard
self.drawCard=addCard
end
table.sort(self.cardList)
local res = self:tryWin(player)
return res
table.sort(self.cardList)
return self:tryWin(player)
end
function M.tingPai(player, room)
local self = setmetatable({}, {__index = M})
local tingList = {}
local cardInhand = player.handcard_list
if not cardInhand or #cardInhand == 0 then
return tingList
end
local kan_huxi = 0
local kan_cards = {}
if player.tiCount==nil then
player.tiCount = 0
end
if player.paoCount==nil then
player.paoCount = 0
end
for j = 1, #player.fz_list do
for i = 1, #cardInhand do
if cardInhand[i] == player.fz_list[j].active_card and player.fz_list[j].type == 3 then
kan_cards[#kan_cards + 1] = cardInhand[i]
break
end
if player.fz_list[j].type==6 then
player.paoCount = 1
if cardType(player.fz_list[j].active_card) ==2 then
kan_huxi = kan_huxi + 9
else
kan_huxi = kan_huxi + 6
end
end
if player.fz_list[j].type==7 then
player.tiCount = 1
if cardType(player.fz_list[j].active_card) ==2 then
kan_huxi = kan_huxi + 12
else
kan_huxi = kan_huxi + 9
end
end
if player.fz_list[j].type==2 then
if cardType(player.fz_list[j].active_card) ==2 then
kan_huxi = kan_huxi + 3
else
kan_huxi = kan_huxi + 1
end
end
end
end
if #kan_cards > 0 then
for i = 1, #kan_cards do
if cardType(kan_cards[i])==2 then
if kan_cards[i] > 200 then
kan_huxi = kan_huxi + 6
else
kan_huxi = kan_huxi + 3
end
removeCard(cardInhand, kan_cards[i], 3)
end
end
player.tiCount = 0
player.paoCount = 0
if #player.fz_list > 0 then
for i = 1, #player.fz_list do
if player.fz_list[i].type == 6 then
player.paoCount = player.paoCount + 1
elseif player.fz_list[i].type == 7 then
player.tiCount = player.tiCount + 1
end
end
end
for k = 100, 200, 100 do
for i = 1, 10 do
local tem = k + i
local result = init(self, player, cardInhand, tem)
local num = 0
for k = 1, #self.stackHuxi do
num = num + self.stackHuxi[k]
end
if result then
local num1 = 0
for k = 1, #self.stackHuxi do
num1 = num1 + self.stackHuxi[k]
end
if (player.hu_xi + num1 + kan_huxi) >= (self:getHuxi(room)-1) then
tingList[#tingList + 1] = tem
end
end
if result == false or (player.hu_xi + num + kan_huxi) < (self:getHuxi(room)) then
if #player.fz_list > 0 then
for k = 1, #player.fz_list do
if tem == player.fz_list[k].active_card then
local ctype = player.fz_list[k].type
if ctype == 2 or ctype == 3 or ctype == 4 or ctype == 5 then
local paohu = init(self, player, cardInhand)
if paohu then
local num2 = 0
for j = 1, #self.stackHuxi do
num2 = num2 + self.stackHuxi[j]
end
if
(num2 + player.hu_xi + kan_huxi + self:GetFzData(tem, ctype)) >=
(self:getHuxi(room))
then
tingList[#tingList + 1] = tem
end
end
end
end
end
end
else
local num1 = 0
for k = 1, #self.stackHuxi do
num1 = num1 + self.stackHuxi[k]
end
if (player.hu_xi + num1 + kan_huxi) >= (self:getHuxi(room)) then
tingList[#tingList + 1] = tem
end
end
end
end
return tingList
@ -497,11 +416,12 @@ function M:getHuxi(room)
if room.game_id == 301 then
return 8
end
if room.room_config.config.hunum==0 then
if room.game_id == 15 then
return 15
end
if room.game_id == 17 then
return 15
end
if room.game_id == 13 or room.game_id == 14 or room.game_id == 23 then
return 15
elseif room.game_id == 26 then
@ -517,19 +437,18 @@ end
function M:GetFzData(tem, ctype)
local huxi
if ctype == 1 then
huxi=1
elseif ctype == 2 then
huxi=1
if ctype == 2 then
if tem > 200 then
huxi = 6
else
huxi = 5
end
elseif ctype == 3 then
huxi = 3
elseif ctype == 4 then
huxi = 3
elseif ctype == 5 then
huxi = 3
elseif ctype == 7 then
huxi = 5
end
return huxi
end

View File

@ -16,6 +16,15 @@ local function checkCard(eventCard, cardList, num)
return false
end
local function cardType(card)
if card>200 then
return 2
else
return 1
end
end
-- 移除指定数量的牌
local function removeCard(cardList, card, count)
for i = 1, count do
@ -45,9 +54,11 @@ end
local M = {
pair_count = 0,
pairflag = 0,
cardList = nil,
stack = nil,
stackHuxi = nil
stackHuxi = nil,
handCardList = nil
}
function M:push(cardGroup)
@ -65,37 +76,122 @@ function M:rollBack()
end
table.sort(self.cardList)
end
-- 顺子
function M:tryShunzi1(card, player)
printlog("tryShunzi1")
if card < 300 and card % 100 > 8 then
return false
end
if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then
removeCard(self.cardList, card + 1, 1)
removeCard(self.cardList, card + 2, 1)
removeCard(self.cardList, card, 1)
local cardGroup = {card, card + 1, card + 2}
--坎
function M:tryKezi(card, player)
if cardNum(card, self.cardList)>=3 then
removeCard(self.cardList, card, cardNum(card, self.cardList))
local cardGroup = {card, card, card}
self:push(cardGroup)
local _huxi = 0
if cardType(card)==1 then
_huxi = 3
else
_huxi = 6
end
self:pushhuxi(_huxi)
return true
end
return false
end
--顺子1
function M:tryShunzi1(card, player)
if card < 200 and card % 100 > 8 then
return false
end
if (cardNum(card + 1, self.cardList)> 0 and cardNum(card + 2, self.cardList) > 0 ) 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}
self:push(cardGroup)
local _huxi = 0
if card%100==1 then
if card>200 then
_huxi = 6
else
_huxi = 3
end
end
self:pushhuxi(_huxi)
return true
end
return false
end
--顺子2
function M:tryShunzi2(card, player)
if cardType(card) == 1 then
if cardNum(card+100,self.cardList) >= 1 and cardNum(card,self.cardList)>=2 then
removeCard(self.cardList, card, 2)
removeCard(self.cardList, card + 100, 1)
local cardGroup = {card, card, card+100}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
return true
end
if cardNum(card+100,self.cardList)>=2 then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card+100, 2)
local cardGroup = {card, card+100, card+100}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
return true
end
else
if cardNum(card-100,self.cardList) >= 1 and cardNum(card,self.cardList)>=2 then
removeCard(self.cardList, card, 2)
removeCard(self.cardList, card - 100, 1)
local cardGroup = {card, card, card-100}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
return true
end
if cardNum(card-100,self.cardList)>=2 then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-100, 2)
local cardGroup = {card, card-100, card-100}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
return true
end
end
return false
end
-- 2 7 10
function M:tryShunzi3(card, player)
printlog("tryShunzi3")
if card % 100 == 2 then
if (checkCard(card + 5, self.cardList, 1)) and (checkCard(card + 8, self.cardList, 1)) then
if cardNum(card + 5, self.cardList)>0 and cardNum(card + 8, self.cardList)>0 then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card + 5, 1)
removeCard(self.cardList, card + 8, 1)
local cardGroup = {card, card + 5, card + 8}
self:push(cardGroup)
local _huxi = 1
local _huxi = 3
self:pushhuxi(_huxi)
return true
end
else
if cardNum(card + 5, self.cardList)>0 and cardNum(card + 8, self.cardList)>0 then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card + 5, 1)
removeCard(self.cardList, card + 8, 1)
local cardGroup = {card, card + 5, card + 8}
self:push(cardGroup)
local _huxi = 3
self:pushhuxi(_huxi)
return true
end
@ -103,186 +199,7 @@ function M:tryShunzi3(card, player)
return false
end
-- 坎
function M:tryKezi(card, player)
printlog("tryKezi")
if (checkCard(card, self.cardList, 3)) then
removeCard(self.cardList, card, 3)
local cardGroup = {card, card, card}
self:push(cardGroup)
local _huxi = 1
if self.drawCard~=card then
_huxi = 3
end
self:pushhuxi(_huxi)
return true
end
return false
end
function M:tryPair(card)
printlog("tryPair")
if (self.pair_count > 0) then
return false
end
printlog(card)
pt(self.cardList)
if (checkCard(card, self.cardList, 2)) then
printlog("checkCard 2")
removeCard(self.cardList, card, 2)
local cardGroup = {card, card}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self.pair_count = 1
return true
elseif (checkCard(card, self.cardList, 1)) then
printlog("checkCard 1")
if card % 100 <=9 then
if (checkCard(card+1, self.cardList, 1)) then
printlog("checkCard 12")
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card+1, 1)
local cardGroup = {card, card+1}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
end
if card % 100 <=8 then
if (checkCard(card+2, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card+2, 1)
local cardGroup = {card, card+2}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
end
if card % 100 >=2 then
if (checkCard(card-1, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-1, 1)
local cardGroup = {card, card-1}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
end
if card % 100 >=3 then
if (checkCard(card-2, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-2, 1)
local cardGroup = {card, card-2}
self:push(cardGroup)
local _huxi = 0
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
end
if card % 100 ==2 then
if (checkCard(card+5, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card+5, 1)
local cardGroup = {card, card+5}
self:push(cardGroup)
local _huxi = 1
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
if (checkCard(card+8, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card+8, 1)
local cardGroup = {card, card+8}
self:push(cardGroup)
local _huxi = 1
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
end
if card % 100 ==7 then
if (checkCard(card-5, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-5, 1)
local cardGroup = {card, card-5}
self:push(cardGroup)
local _huxi = 1
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
if (checkCard(card+3, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card+3, 1)
local cardGroup = {card, card+3}
self:push(cardGroup)
local _huxi = 1
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
end
if card % 100 ==10 then
if (checkCard(card-8, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-8, 1)
local cardGroup = {card, card-8}
self:push(cardGroup)
local _huxi = 1
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
if (checkCard(card-3, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-3, 1)
local cardGroup = {card, card-3}
self:push(cardGroup)
local _huxi = 1
self:pushhuxi(_huxi)
self.pair_count = 1
return true
end
end
end
return false
end
function M:tryPair2(card)
printlog("tryPair2")
if (self.pair_count > 0) then
return false
end
@ -341,7 +258,7 @@ function M:tryPair2(card)
end
if card % 100 ==10 then
if card % 100 == 10 then
if (checkCard(card-8, self.cardList, 1)) then
removeCard(self.cardList, card, 1)
removeCard(self.cardList, card-8, 1)
@ -373,14 +290,32 @@ function M:tryPair2(card)
return false
end
function M:tryPair(card)
if (self.pair_count > 0) then
return false
end
if cardNum(card, self.cardList)>=2 then
self.pairflag = 1
removeCard(self.cardList, card, 2)
local cardGroup = {card, card , card}
self:push(cardGroup)
self.pair_count = 1;
local _huxi = 0
self:pushhuxi(_huxi)
return true
end
end
function M:tryWin(player)
if #self.cardList == 0 then
--[[ if #self.cardList == 0 then
if (self.pair_count == 1) then
return true
elseif self.pair_count == 2 and #self.stack==2 then
elseif #self.stack>=2 then
local tempPList={}
for i=1,#self.stack do
local card1=self.stack[i][1]
@ -401,36 +336,37 @@ function M:tryWin(player)
return false
end
]]
if #self.cardList == 0 then
if (player.tiCount+player.paoCount)>0 then
if self.pair_count ==1 then
return true
end
return false
else
if self.pair_count >0 then
return false
end
return true
end
end
local activeCard = 0
for i = 1, #self.cardList do
if (self.cardList[i] == 201 or self.cardList[i] == 202) then
activeCard = self.cardList[i]
break
end
end
if (activeCard == 0) then
activeCard = self.cardList[1]
end
print("check win:")
-- pt(self.cardList)
print("activeCard:"..activeCard)
if (activeCard % 100 == 1) then
if self:tryShunzi1(activeCard, player) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryKezi(activeCard, player) then
if self:tryWin(player) then
@ -440,24 +376,39 @@ function M:tryWin(player)
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryPair(activeCard) then
if self:tryShunzi1(activeCard, player) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryPair2(activeCard) then
if self:tryShunzi2(activeCard, player) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryShunzi3(activeCard, player) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if (player.tiCount + player.paoCount)>0 then
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
end
elseif activeCard % 100 == 2 then
@ -468,6 +419,7 @@ function M:tryWin(player)
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryKezi(activeCard, player) then
if self:tryWin(player) then
return true
@ -476,25 +428,7 @@ function M:tryWin(player)
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryPair2(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryShunzi1(activeCard, player) then
if self:tryShunzi1(activeCard, player) then
if self:tryWin(player) then
return true
end
@ -502,8 +436,13 @@ function M:tryWin(player)
table.remove(self.stackHuxi, #self.stackHuxi)
end
else
if self:tryShunzi2(activeCard, player) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryShunzi3(activeCard, player) then
if self:tryWin(player) then
return true
@ -512,6 +451,27 @@ function M:tryWin(player)
table.remove(self.stackHuxi, #self.stackHuxi)
end
if (player.tiCount + player.paoCount)>0 then
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
end
else
if self:tryShunzi2(activeCard, player) then
if self:tryWin(player) then
return true
end
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryKezi(activeCard, player) then
if self:tryWin(player) then
return true
@ -520,28 +480,7 @@ function M:tryWin(player)
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryPair2(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
if self:tryShunzi1(activeCard, player) then
if self:tryShunzi1(activeCard, player) then
if self:tryWin(player) then
return true
end
@ -551,21 +490,111 @@ function M:tryWin(player)
if (player.tiCount + player.paoCount)>0 then
if self:tryPair(activeCard) then
if self:tryWin(player) then
return true
end
self.pair_count = 0
self:rollBack()
table.remove(self.stackHuxi, #self.stackHuxi)
end
end
-- end
end
return false
end
local function initnew(self,player,cardInhand,addCard)
-- 方案一获取获取pao子坎子顺子话子对子将
self.stack = {}
self.stackHuxi = {}
self.pair_count = 0
self.kong_count = 0
self.drawCard=0
self.cardList = membe_clone(cardInhand)
self.handCardList = membe_clone(cardInhand)
local tmpchongfu = {}
self.handCardList[#self.handCardList+1] = addCard
for i = 1, #self.handCardList do
--获取重复
if tmpchongfu[self.handCardList[i]] ~=nil then
tmpchongfu[self.handCardList[i]] = tmpchongfu[self.handCardList[i]] + 1
else
tmpchongfu[self.handCardList[i]] = 1
end
end
for index, value in pairs(tmpchongfu) do
if value>=3 then
if value==4 then
player.paoCount = player.paoCount+1
end
removeCard(self.handCardList,index,value)
local _huxi = 0
if cardType(index)==1 then
_huxi = 6
else
_huxi = 9
end
self:pushhuxi(_huxi)
end
end
-- pt(tmpchongfu)
-- pt(self.handCardList)
self.cardList = membe_clone( self.handCardList )
-- pt(self.cardList)
table.sort(self.cardList)
--[[local activeCard = 109
self.cardList = {
107,207,109,109,209
}]]
-- local res1 = self:tryShunzi2(activeCard, player)
local res1 = self:tryWin(player)
printlog(res1)
end
local function init(self, player, cardInhand, addCard)
self.stack = {}
self.stackHuxi = {}
self.pair_count = 0
self.kong_count = 0
self.drawCard=0
print("+++++++++++++++++++++++++++++++++++++++++++++++++")
self.handCardList = membe_clone(cardInhand)
local tmpchongfu = {}
self.handCardList[#self.handCardList+1] = addCard
for i = 1, #self.handCardList do
--获取重复
if tmpchongfu[self.handCardList[i]] ~=nil then
tmpchongfu[self.handCardList[i]] = tmpchongfu[self.handCardList[i]] + 1
else
tmpchongfu[self.handCardList[i]] = 1
end
end
for index, value in pairs(tmpchongfu) do
if value==4 then
player.paoCount = player.paoCount+1
-- self.tiZi[index] = 1
end
if value == 2 then
self.pairflag = 1
end
end
self.cardList = membe_clone(cardInhand)
--[[
if addCard == nil then
self.kong_count = 1
else
@ -573,58 +602,89 @@ local function init(self, player, cardInhand, addCard)
self.cardList[#self.cardList + 1] = addCard
self.drawCard=addCard
end
]]
table.sort(self.cardList)
self.cardList = {106,107,108,109}
local eventCard = 108
--local cardList ={108,109}
local res = self:tryWin(player)
local res = self:tryPair(eventCard)
--local res = self:tryWin(player)
print("jefe check res")
print(res)
return false -- res
return res
end
function M.tingPai(player, room)
local self = setmetatable({}, {__index = M})
local tingList = {}
local cardInhand = player.handcard_list
self.tiZi = {}
if not cardInhand or #cardInhand == 0 then
return tingList
end
local kan_huxi = 0
local kan_cards = {}
if player.tiCount==nil then
player.tiCount = 0
end
if player.paoCount==nil then
player.paoCount = 0
end
for j = 1, #player.fz_list do
for i = 1, #cardInhand do
if cardInhand[i] == player.fz_list[j].active_card and player.fz_list[j].type == 3 then
kan_cards[#kan_cards + 1] = cardInhand[i]
self.tiZi[cardInhand[i]] = 1
break
end
end
if player.fz_list[j].type==6 then
player.paoCount = 1
if cardType(player.fz_list[j].active_card) ==2 then
kan_huxi = kan_huxi + 9
else
kan_huxi = kan_huxi + 6
end
end
if player.fz_list[j].type==7 then
player.tiCount = 1
if cardType(player.fz_list[j].active_card) ==2 then
kan_huxi = kan_huxi + 12
else
kan_huxi = kan_huxi + 9
end
end
if player.fz_list[j].type==2 then
if cardType(player.fz_list[j].active_card) ==2 then
kan_huxi = kan_huxi + 3
else
kan_huxi = kan_huxi + 1
end
end
end
if #kan_cards > 0 then
for i = 1, #kan_cards do
kan_huxi = kan_huxi + 3
if cardType(kan_cards[i])==2 then
kan_huxi = kan_huxi + 6
else
kan_huxi = kan_huxi + 3
end
removeCard(cardInhand, kan_cards[i], 3)
end
end
player.tiCount = 0
player.paoCount = 0
-- for k = 100, 200, 100 do
-- for i = 1, 10 do
local tem =106 -- k + i
for k = 100, 200, 100 do
for i = 1, 10 do
local tem = k + i
-- player.paoCount = 1
local result = init(self, player, cardInhand, tem)
--补充 验证
-- local result2 = initnew(self,player,cardInhand,tem)
local num = 0
for k = 1, #self.stackHuxi do
@ -633,20 +693,23 @@ function M.tingPai(player, room)
if result then
local num1 = 0
--pt(self.stackHuxi)
for k = 1, #self.stackHuxi do
num1 = num1 + self.stackHuxi[k]
--printlog(self.stackHuxi[k])
end
if (player.hu_xi + num1 + kan_huxi) >= (self:getHuxi(room)-1) then
tingList[#tingList + 1] = tem
end
end
print("==============================================================")
--return
--end
-- end
end
end
if next(self.tiZi)~=nil and #tingList > 0 and self.pairflag>0 then
for key, value in pairs(self.tiZi) do
if value>0 then
tingList[#tingList + 1] = key
end
end
end
return tingList
end

View File

@ -121,26 +121,42 @@ room.room_config = {
}
player.hu_xi = 0
player.handcard_list ={106,107,105,109,109,205,205,205,204,204,204,108,108,108,201,201,202,207,210,209}
player.handcard_list ={ 102,
102,
103,
104,
106,
106,
107,
107,
110,
110,
203,
204,
205,
206,
}
player.fz_list = {
--[[
{
type = 2,
active_card = 208,
opcard = {208,208},
card = 208,
},
{
type = 1,
card = 204,
opcard = {
203,
202,
},
active_card = 204,
}]]
{
type = 2,
card = 208,
opcard = {
208,
208,
},
active_card = 208,
},
{
type = 1,
card = 109,
opcard = {
109,
209,
},
active_card = 109,
}
}
CardCheck.tingPai(player,room)

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="1334,750" designImage="ui://3vytbifonu0l2f" designImageOffsetX="-200" designImageOffsetY="-100">
<controller name="state" pages="0,准备状态,1,游戏状态,2,回合间状态,3,回放状态" selected="3"/>
<controller name="state" pages="0,准备状态,1,游戏状态,2,回合间状态,3,回放状态" selected="1"/>
<controller name="sdk" pages="0,,1," selected="0"/>
<controller name="action" pages="2,空,0,准备,1,开始" selected="0"/>
<controller name="jushu" pages="0,,1," selected="0"/>
@ -27,7 +27,7 @@
<component id="n147_nu0l" name="player_info2" src="f55qw7" fileName="component/Main/component/PlayerHead_2.xml" xy="11,71">
<relation target="" sidePair="left-left,leftext-left"/>
</component>
<component id="n7" name="player_info1" src="f55qw4" fileName="component/Main/component/PlayerHead_1.xml" xy="8,570" size="189,67">
<component id="n7" name="player_info1" src="f55qw4" fileName="component/Main/component/PlayerHead_1.xml" xy="22,548" size="189,67">
<gearXY controller="state" pages="0,1,2,3" values="20,524|22,548|8,570|8,570"/>
<relation target="" sidePair="left-left,leftext-left"/>
</component>
@ -83,11 +83,11 @@
<gearDisplay controller="state" pages="3"/>
<relation target="" sidePair="center-center"/>
</image>
<text id="n42_lryk" name="tex_round" xy="527,150" size="267,36" group="n154_r1mo" fontSize="24" color="#ffffff" align="center" autoSize="none" text="剩余 5 张牌 1/8局">
<text id="n42_lryk" name="tex_round" xy="565,150" size="267,36" group="n154_r1mo" fontSize="24" color="#ffffff" align="center" autoSize="none" text="剩余 5 张牌 1/8局">
<gearDisplay controller="state" pages="1,3"/>
<relation target="" sidePair="center-center"/>
</text>
<group id="n154_r1mo" name="n154" xy="527,150" size="267,36" advanced="true">
<group id="n154_r1mo" name="n154" xy="565,150" size="267,36" advanced="true">
<gearDisplay controller="jushu" pages="1"/>
</group>
<loader id="n153_8th3" name="cardAnima" xy="625,86" size="50,30" visible="false" touchable="false" url="ui://3bfrwj0h8th37l" autoSize="true">
@ -116,7 +116,7 @@
<component id="n179_kxwj" name="btn_distance" src="kxwjhyc" fileName="component/gps/btn_distance_new.xml" pkg="27vd145b" xy="1248,262" visible="false" touchable="false">
<gearDisplay controller="state" pages="0,1,2"/>
</component>
<text id="n27" name="remaining_card" xy="625,93" size="165,45" fontSize="32" color="#ffffff" align="center" autoSize="none" text="剩余20张">
<text id="n27" name="remaining_card" xy="617,92" size="165,45" fontSize="32" color="#ffffff" align="center" autoSize="none" text="剩余20张">
<gearDisplay controller="state" pages="1,3"/>
<relation target="" sidePair="center-center"/>
</text>

Binary file not shown.

View File

@ -14,10 +14,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_PixelRect:
serializedVersion: 2
x: 12
y: 66.66667
x: 1.3333334
y: 50
width: 876.6667
height: 854.6667
height: 860.6667
m_ShowMode: 4
m_Title:
m_RootView: {fileID: 4}
@ -40,9 +40,9 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 384
y: 387
width: 877
height: 421
height: 424
m_MinSize: {x: 101, y: 121}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 9}
@ -72,7 +72,7 @@ MonoBehaviour:
x: 0
y: 0
width: 877
height: 805
height: 811
m_MinSize: {x: 201, y: 342}
m_MaxSize: {x: 4001, y: 8042}
vertical: 1
@ -98,7 +98,7 @@ MonoBehaviour:
x: 0
y: 0
width: 877
height: 855
height: 861
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
--- !u!114 &5
@ -142,7 +142,7 @@ MonoBehaviour:
x: 0
y: 30
width: 877
height: 805
height: 811
m_MinSize: {x: 201, y: 342}
m_MaxSize: {x: 4001, y: 8042}
vertical: 0
@ -163,7 +163,7 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 835
y: 841
width: 877
height: 20
m_MinSize: {x: 0, y: 0}
@ -186,7 +186,7 @@ MonoBehaviour:
x: 0
y: 0
width: 877
height: 384
height: 387
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 12}
@ -216,10 +216,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 12
y: 480.6667
x: 1.3333334
y: 467.33334
width: 876
height: 400
height: 403
m_ViewDataDictionary: {fileID: 0}
--- !u!114 &10
MonoBehaviour:
@ -431,10 +431,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 12
y: 96.66667
x: 1.3333334
y: 80
width: 876
height: 363
height: 366
m_ViewDataDictionary: {fileID: 0}
m_SerializedViewNames: []
m_SerializedViewValues: []
@ -471,7 +471,7 @@ MonoBehaviour:
m_HSlider: 0
m_VSlider: 0
m_IgnoreScrollWheelUntilClicked: 0
m_EnableMouseInput: 1
m_EnableMouseInput: 0
m_EnableSliderZoomHorizontal: 0
m_EnableSliderZoomVertical: 0
m_UniformScale: 1
@ -481,22 +481,22 @@ MonoBehaviour:
x: 0
y: 21
width: 876
height: 342
m_Scale: {x: 0.475, y: 0.475}
m_Translation: {x: 438, y: 171}
height: 345
m_Scale: {x: 0.47916666, y: 0.47916666}
m_Translation: {x: 438, y: 172.5}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -922.1053
x: -914.087
y: -360
width: 1844.2106
width: 1828.174
height: 720
m_MinimalGUI: 1
m_defaultScale: 0.475
m_LastWindowPixelSize: {x: 1314, y: 544.5}
m_defaultScale: 0.47916666
m_LastWindowPixelSize: {x: 1314, y: 549}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 00000001000000000000

Binary file not shown.

View File

@ -0,0 +1,2 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2019.4.10f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2019.4.10f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler