hengyang_client/lua_probject/extend_project/extend/majiang/qizhiba/MJPlayerSelfCardInfoView.lua

197 lines
6.7 KiB
Lua
Raw Normal View History

2025-04-01 10:48:36 +08:00
local MJPlayerSelfCardInfoView = import(".main.MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = import(".main.MJPlayerCardInfoView")
local CardCheck = import(".CardCheck")
local M = {}
2025-04-11 12:49:08 +08:00
--
function M.new(view, mainView)
setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView })
setmetatable(M, { __index = MJPlayerSelfCardInfoView })
local self = setmetatable({}, { __index = M })
2025-04-01 10:48:36 +08:00
self.class = "PlayerSelfCardInfoView"
self._view = view
self._mainView = mainView
self:init()
return self
end
2025-04-11 12:49:08 +08:00
function M:ShowHuTip(card_list, currentOnclickCard)
if currentOnclickCard then
if DataManager.CurrenRoom.self_player.CardTingList then
local tempV = DataManager.CurrenRoom.self_player.CardTingList[currentOnclickCard]
if tempV and #tempV > 0 then
self._mainView._hu_tip:FillData(tempV)
else
self._mainView._hu_tip:HideHuTipsPanel()
end
end
else
--[[if DataManager.CurrenRoom.self_player.allTingPaiList and #DataManager.CurrenRoom.self_player.allTingPaiList>0 then
2025-04-01 10:48:36 +08:00
self._mainView._hu_tip:FillData(DataManager.CurrenRoom.self_player.allTingPaiList)
end--]]
2025-04-11 12:49:08 +08:00
end
2025-04-01 10:48:36 +08:00
end
function M:UpdateHandCard(getcard, mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList
2025-04-11 12:49:08 +08:00
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
2025-04-01 10:48:36 +08:00
local card_list = DataManager.CurrenRoom.self_player.card_list
self:ShowHuTip(card_list)
if getcard then
self._out_card = true
2025-04-11 12:49:08 +08:00
if DataManager.CurrenRoom.self_player.tingPaiList and #DataManager.CurrenRoom.self_player.tingPaiList > 0 then
for i = 1, #_carViewList do
local btn = _carViewList[i].card
local isTing, curIndex = CheckDictionaryFromContent(_carViewList[i].card_item,
DataManager.CurrenRoom.self_player.tingPaiList)
if isTing then
--printlog("听牌提示===》》》",curIndex)
--pt(DataManager.CurrenRoom.self_player.tingPaiList[curIndex])
local value = #DataManager.CurrenRoom.self_player.tingPaiList[curIndex].value
if tonumber(value) > 1 then
btn:GetController("mark_ting").selectedIndex = 2
else
btn:GetController("mark_ting").selectedIndex = 1
end
end
end
end
--DataManager.CurrenRoom.self_player.tingPaiList=nil
2025-04-01 10:48:36 +08:00
else
for i = 1, #_carViewList do
local btn = _carViewList[i].card
if btn:GetController("mark_ting").selectedIndex ~= 0 then
btn:GetController("mark_ting").selectedIndex = 0
end
end
self._out_card = false
end
end
function M:__OnClickHandCard(context)
local button = context.sender
local _carViewList = self._carViewList
local refresh = true
local card_list = {}
2025-04-11 12:49:08 +08:00
for i = 1, #_carViewList do
2025-04-01 10:48:36 +08:00
local btn = _carViewList[i].card
local card = self:GetCard(btn)
2025-04-11 12:49:08 +08:00
if btn ~= button and btn.selected == true then
2025-04-01 10:48:36 +08:00
if button.data.card_item == card then
refresh = false
else
self._mainView:markOutCards(false, card)
end
btn.selected = false
2025-04-11 12:49:08 +08:00
end
2025-04-01 10:48:36 +08:00
if not btn.selected then
table.insert(card_list, card)
end
end
if self._out_card then
2025-04-11 12:49:08 +08:00
printlog("点击开始出牌===>>>")
self:ShowHuTip(card_list, button.data.card_item)
2025-04-01 10:48:36 +08:00
end
-- 标记出牌
if refresh then
if button.selected then
self._mainView:markOutCards(true, button.data.card_item)
else
self._mainView:markOutCards(false, button.data.card_item)
end
end
local _room = DataManager.CurrenRoom
if not button.selected and _room.curren_outcard_seat == _room.self_player.seat then
local card = button.data
self._mainView:OutCard(card.card_item)
end
end
function M:__OnDragStart(card)
local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
list_remove(card_list, card)
self:ShowHuTip(card_list)
end
function M:__OnDragEnd(context)
2025-04-11 12:49:08 +08:00
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
2025-04-01 10:48:36 +08:00
local button = context.sender
2025-04-11 12:49:08 +08:00
2025-04-01 10:48:36 +08:00
--button:RemoveFromParent()
local card = button.data
local _room = DataManager.CurrenRoom
2025-04-11 12:49:08 +08:00
-- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat)
local isOut = IsHasDictionary(card.card_item, DataManager.CurrenRoom.laiziInfo)
if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and isOut == false) then
2025-04-01 10:48:36 +08:00
self._mainView:OutCard(card.card_item)
button.touchable = false
self.outcard_button = button
else
self._area_handcard_list:AddChildAt(button, card.index)
button:TweenMove(card.old_postion, 0.2)
end
end
function M:CheckPlayerOnlineState()
local room = DataManager.CurrenRoom
for i = 1, #room.player_list do
if room.player_list[i].line_state == 0 then
return false
end
end
return true
end
2025-04-11 12:49:08 +08:00
2025-04-01 10:48:36 +08:00
function M:Clear(bskip)
--self._ctr_state.selectedIndex = 0
self._area_fz_list.x = self._src_fz_list.x
self._area_fz_list.y = self._src_fz_list.y
self._area_fz_list.width = self._src_fz_list.z
self._area_fz_list.height = self._src_fz_list.w
self._area_fz_list:RemoveChildren(0, -1, true)
self._area_handcard_list:RemoveChildren(0, -1, true)
self._area_outcard_list:RemoveChildren(0, -1, true)
if bskip == nil or bskip == false then
self._mask_liangpai:RemoveChildren(0, -1, true)
end
2025-04-11 12:49:08 +08:00
for i = 1, #self._carViewList do
2025-04-01 10:48:36 +08:00
self._carViewList[i].card:Dispose()
end
self._carViewList = {}
end
2025-04-11 12:49:08 +08:00
return M