新二三四人页面全应用

master
罗家炜 2025-04-26 16:08:52 +08:00
parent ad2767352b
commit 5bb5f1774b
9 changed files with 698 additions and 543 deletions

View File

@ -1,6 +1,7 @@
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local MJMainView = require("main.majiang.MJMainView")
local TableBG = require("Game.Data.TableBG")
local EXClearingView = import(".EXClearingView")
local TX_GameEvent = import(".GameEvent")
local HuTipView = import("main.majiang.HuTipView")
@ -8,6 +9,13 @@ local SettingView = import(".EXSettingView")
local PlayerInfoView = import(".EXPlayerInfoView")
local M = {}
local bg_config = {
{ id = 1, url = "extend/majiang/nancheng/bg/bg1", thumb = "ui://Extend_MJ_NanCheng/bg1" },
{ id = 2, url = "extend/majiang/nancheng/bg/bg2", thumb = "ui://Extend_MJ_NanCheng/bg2" },
{ id = 3, url = "extend/majiang/nancheng/bg/bg3", thumb = "ui://Extend_MJ_NanCheng/bg3" },
{ id = 4, url = "extend/majiang/nancheng/bg/bg4", thumb = "ui://Extend_MJ_NanCheng/bg4" }
}
--- Create a new ZZ_MainView
function M.new()
setmetatable(M, { __index = MJMainView })
@ -25,10 +33,16 @@ function M:InitView(url)
self._gps_style = 1
self._full = true
UIPackage.AddPackage("extend/majiang/fuzhou/ui/Extend_MJ_FuZhou")
if self._room.room_config.people_num == 2 then
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
else
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
-- if self._room.room_config.people_num == 2 then
-- MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
-- else
-- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
-- end
local use_custom_bg = true
MJMainView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num),
use_custom_bg)
if use_custom_bg then
TableBG.LoadTableBG(1, self._room.game_id, self._root_view, bg_config)
end
self._hu_tip = HuTipView.new(self)
@ -46,9 +60,17 @@ function M:InitView(url)
--[[
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
--]]
local config = ExtendManager.GetExtendConfig(room.game_id)
local mode = config:GetGameInfo()
local gamePlay = mode:LoadConfigToDetail(json.encode(room.room_config.config))
self._view:GetChild('wanfa_text').text = gamePlay
self.jing = self._view:GetChild('jing')
self._state.onChanged:Add(function()
self:UpdatePlayerInfoView()
end)
local showNextCtr = self._view:GetController('showNext')
local ShowNextConfrimCtr = self._view:GetController('showNextConfrim')
local showNextList = self._view:GetChild('list_showNext')
@ -84,7 +106,6 @@ function M:InitView(url)
showNextList.selectedIndex = -1
self._showNextName = nil
end)
if self._room.room_config.people_num == 2 then
local btn_closeRoom = self._view:GetChild("btn_setting")
self._view:GetChild('btn_closeRoom').onClick:Set(function()
@ -126,7 +147,6 @@ function M:InitView(url)
local settingView = SettingView.new(self)
settingView:Show()
end))
end
--------
self:PlayerChangeLineState()
@ -186,13 +206,8 @@ function M:IsShowGangZi(btn, isShow)
end
function M:UpdateRound()
if self._room.room_config.people_num == 2 then
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
self._room.room_config.round)
else
self._view:GetChild("tex_round1").text = self._room.curren_round
self._view:GetChild("tex_round2").text = self._room.room_config.round
end
end
function M:ShowJing()
@ -212,12 +227,24 @@ function M:InitPlayerInfoView()
self._player_info = {}
local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild("player_info" .. i)
local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
tem.visible = false
end
end
function M:UpdatePlayerInfoView()
self._player_info = {}
local _player_info = self._player_info
local list = self._room.player_list
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
_player_info[i]:FillData(list[i])
end
end
function M:NewMJPlayerCardInfoView(view, index)
if index == 1 then
return MJPlayerSelfCardInfoView.new(view, self)
@ -356,7 +383,7 @@ function M:EventInit()
local player = _room:GetPlayerBySeat(win_seat)
if win_seat ~= _room.self_player.seat then
url = "ui://Main_Majiang/别人胡"
pNode = info._mask_liangpai
pNode = info._view
elseif win_seat == _room.self_player.seat then
url = "ui://Main_Majiang/自己胡牌"
pNode = self._view
@ -443,16 +470,16 @@ function M:EventInit()
local liuju = result.liuju
local data = result.info_list
local niao = result.niao
if liuju then
local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
self._view:AddChild(le)
le:Center()
le:GetTransition("t0"):Play()
coroutine.start(function()
coroutine.wait(1)
le:Dispose()
end)
end
-- if liuju then
-- local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
-- self._view:AddChild(le)
-- le:Center()
-- le:GetTransition("t0"):Play()
-- coroutine.start(function()
-- coroutine.wait(1)
-- le:Dispose()
-- end)
-- end
self:RemoveCursor()
if self._clearingView == nil then
self._clearingView = EXClearingView.new(self._root_view)
@ -496,7 +523,7 @@ function M:EventInit()
self._clearingView = nil
end)
end
self._player_card_info[1]:ShowHuTip()
-- self._player_card_info[1]:ShowHuTip()
end)
_gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...)
@ -563,59 +590,119 @@ function M:OutCard(card)
end
end
-- function M:__FangziTip(tip, weight)
-- printlog("__FangziTip")
-- local _gamectr = self._gamectr
-- local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips")
-- _chipeng_tip:GetController("hide_bg").selectedIndex = 1
-- self._chipeng_tip = _chipeng_tip
-- local p = self._room.self_player
-- -- self._player_card_info[self:GetPos(p.seat)]
-- local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi")
-- _lit_fanzi:RemoveChildrenToPool()
-- local _tlist = table.keys(tip.tip_map_type)
-- printlog(tip.tip_map_type)
-- pt(_tlist)
-- local tip_hu = false
-- local count = #_tlist
-- table.sort(_tlist)
-- local isHu = false
-- for k = 1, #_tlist do
-- local td = tip.tip_map_type[_tlist[k]][1]
-- local url = "ui://Main_Majiang/Btn_fztip"
-- local td_weight = td.weight
-- if td_weight == 16 then td_weight = 8 end
-- if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end
-- local btn_t = _lit_fanzi:AddItemFromPool(url)
-- btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
-- btn_t.data = { tip, td }
-- btn_t.onClick:Add(self.__TipAction, self)
-- end
-- -- if not (tonumber(weight) >= 16) then
-- local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- -- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
-- _btn_pass.onClick:Set(function()
-- if tonumber(weight) >= 8 then
-- local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel)
-- guo_msg.onOk:Add(function()
-- _gamectr:SendAction(0)
-- _chipeng_tip:Dispose()
-- self._chipeng_tip = nil
-- guo_msg:Close()
-- end)
-- guo_msg:Show()
-- else
-- _gamectr:SendAction(0)
-- _chipeng_tip:Dispose()
-- self._chipeng_tip = nil
-- end
-- end)
-- -- end
-- self._view:AddChild(_chipeng_tip)
-- _chipeng_tip:Center()
-- end
function M:__FangziTip(tip, weight)
printlog("__FangziTip")
local _gamectr = self._gamectr
local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips")
_chipeng_tip:GetController("hide_bg").selectedIndex = 1
self._chipeng_tip = _chipeng_tip
local p = self._room.self_player
-- self._player_card_info[self:GetPos(p.seat)]
local info = self._player_card_info[1]
local _chipeng_tip = info._view_FZTips
local _ctr_tips = info._ctr_tip
local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi")
_lit_fanzi:RemoveChildrenToPool()
local _tlist = table.keys(tip.tip_map_type)
printlog(tip.tip_map_type)
pt(_tlist)
local tip_hu = false
local count = #_tlist
table.sort(_tlist)
local isHu = false
for k = 1, #_tlist do
local td = tip.tip_map_type[_tlist[k]][1]
local url = "ui://Main_Majiang/Btn_fztip"
local td_weight = td.weight
if td_weight == 16 then td_weight = 8 end
if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end
local btn_t = _lit_fanzi:AddItemFromPool(url)
btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
btn_t.data = { tip, td }
btn_t.onClick:Add(self.__TipAction, self)
end
-- if not (tonumber(weight) >= 16) then
local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
_btn_pass.onClick:Set(function()
if tonumber(weight) >= 8 then
local _lit_fanzi = _chipeng_tip:GetChild("list")
_lit_fanzi:SetVirtual()
local _tlist = tip.tip_map_id
_lit_fanzi.itemRenderer = function(index, obj)
local type = obj:GetController('type')
if index == tip.tip_num then
type.selectedIndex = 0
obj.onClick:Set(function()
local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel)
guo_msg.onOk:Add(function()
_gamectr:SendAction(0)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
_ctr_tips.selectedIndex = 0
guo_msg:Close()
end)
guo_msg:Show()
else
_gamectr:SendAction(0)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
end
end)
-- end
self._view:AddChild(_chipeng_tip)
_chipeng_tip:Center()
else
index = index + 1
if _tlist[index].type == FZType.HU then
type.selectedIndex = 4
obj:GetChild('btn_Card1').icon = string.format('ui://Main_Majiang/202_%d', _tlist[index].card)
elseif _tlist[index].type == FZType.Chi then
type.selectedIndex = FZType.Chi
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].opcard[i])
end
elseif _tlist[index].type == FZType.Peng then
type.selectedIndex = FZType.Peng
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
else
for i = 1, 4 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
type.selectedIndex = FZType.Gang
if _tlist[index].type == FZType.Gang_An then
obj:GetChild('btn_Card4').icon = 'ui://Main_Majiang/202_00'
end
end
obj.onClick:Set(function()
_gamectr:SendAction(_tlist[index].id)
_ctr_tips.selectedIndex = 0
end)
end
end
_ctr_tips.selectedIndex = 1
_lit_fanzi.numItems = tip.tip_num + 1
end
function M:__TipAction(context)
@ -722,7 +809,7 @@ function M:OnFangziAction(...)
end
effect.touchable = false
effect:GetTransition("t2"):Play()
pNode:AddChild(effect)
-- pNode:AddChild(effect)
coroutine.start(function()
coroutine.wait(0.3)
self._popEvent = true

View File

@ -17,14 +17,7 @@ function M.new(view, mainView)
end
function M:init()
if self._main_view._room.room_config.people_num ~= 2 then
PlayerInfoView.init(self)
self._tex_score = self._view:GetChild("info"):GetChild("tex_score1")
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2")
self._ct_score = self._view:GetChild("info"):GetController("score")
else
PlayerInfoView_copy.init(self)
end
end
function M:ShowInteraction(type,str)
@ -57,12 +50,7 @@ function M:UpdateRemainCard(card_num, hide)
end
function M:FillData(player)
if self._main_view._room.room_config.people_num == 2 then
PlayerInfoView_copy.FillData(self, player)
else
PlayerInfoView.FillData(self, player)
self:UpdateScore(player.total_score)
end
end
function M:UpdateScore()

View File

@ -1,5 +1,5 @@
local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local CardCheck = import(".CardCheck")
local M = {}
@ -15,196 +15,197 @@ function M.new(view, mainView)
return self
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)
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
end
self._mainView._hu_tip:FillData(tingList)
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)
-- 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
-- end
-- self._mainView._hu_tip:FillData(tingList)
-- end
function M:UpdateHandCard(getcard, mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList
-- 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
self._out_card = true
local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
-- 记录需要标记听牌提示的牌
local lst_mark = {}
local total_num = 0
for i = 1, #_carViewList do
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)
if #tingList > 0 then
local count = 0
for j = 1, #tingList do
count = count + self._mainView:CountCardLeftNum(tingList[j])
end
local tem = {}
tem.item = btn
tem.count = count
total_num = total_num + count
table.insert(lst_mark, tem)
end
table.insert(card_list, card)
end
table.sort(lst_mark, function(a, b)
return a.count > b.count
end)
-- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多'
local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false
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
else
tem.item:GetController("mark_ting").selectedIndex = 2
end
end
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
-- local card_list = DataManager.CurrenRoom.self_player.card_list
-- -- self:ShowHuTip(card_list)
-- if getcard then
-- self._out_card = true
-- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
-- -- 记录需要标记听牌提示的牌
-- local lst_mark = {}
-- local total_num = 0
-- for i = 1, #_carViewList do
-- 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)
-- if #tingList > 0 then
-- local count = 0
-- for j = 1, #tingList do
-- count = count + self._mainView:CountCardLeftNum(tingList[j])
-- end
-- local tem = {}
-- tem.item = btn
-- tem.count = count
-- total_num = total_num + count
-- table.insert(lst_mark, tem)
-- end
-- table.insert(card_list, card)
-- end
-- table.sort(lst_mark, function(a, b)
-- return a.count > b.count
-- end)
-- -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多'
-- local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false
-- 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
-- else
-- tem.item:GetController("mark_ting").selectedIndex = 2
-- end
-- end
-- 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 = {}
for i = 1, #_carViewList do
local btn = _carViewList[i].card
local card = self:GetCard(btn)
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
if not btn.selected then
table.insert(card_list, card)
end
end
-- function M:__OnClickHandCard(context)
-- local button = context.sender
-- local _carViewList = self._carViewList
-- local refresh = true
-- local card_list = {}
-- for i = 1, #_carViewList do
-- local btn = _carViewList[i].card
-- local card = self:GetCard(btn)
-- 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
-- if not btn.selected then
-- table.insert(card_list, card)
-- end
-- end
if self._out_card then
-- self:ShowHuTip(card_list)
end
-- if self._out_card then
-- -- self:ShowHuTip(card_list)
-- 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
-- -- 标记出牌
-- 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
-- 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:__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)
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
local button = context.sender
-- function M:__OnDragEnd(context)
-- 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
-- --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)
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
-- -- -- 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)
-- 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
-- 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
function M:Clear(bskip)
MJPlayerSelfCardInfoView.Clear(self)
--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.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
-- 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
for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose()
end
self._carViewList = {}
-- for i = 1, #self._carViewList do
-- self._carViewList[i].card:Dispose()
-- end
-- self._carViewList = {}
end
return M

View File

@ -115,6 +115,7 @@ function M:fillResult0(room, peopleNum, result)
local isZhuang = playerInfoComp:GetController("zhuang")
local infoList = result.info_list[i]
local infoJiangma = result.niao
local playInfo = room:GetPlayerBySeat(infoList.seat)
local fzCardInfo = playInfo.fz_list
local fzInfoNum = #fzCardInfo
@ -122,6 +123,11 @@ function M:fillResult0(room, peopleNum, result)
self:fillHead(playInfo.self_user.head_url, playerInfoComp)
infoList.jing_score = infoList.jing_score or 0
infoList.gang_score = infoList.gang_score or 0
infoList.hu_score = infoList.hu_score or 0
infoList.round_score = infoList.round_score or 0
playerInfoComp:GetChild("text_name").text = playInfo.self_user.nick_name
playerInfoComp:GetChild("Text_BoJing").text = infoList.jing_score >= 0 and
string.format("+%d", infoList.jing_score) or infoList.jing_score
@ -179,7 +185,6 @@ function M:fillResult0(room, peopleNum, result)
handCardList.itemRenderer = function(index, obj)
obj.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), infoList.hand_card[index + 1])
if room.jing == infoList.hand_card[index + 1] then
ViewUtil:ErrorTip("显示精")
obj:GetController('jing').selectedIndex = 1
end
end
@ -191,7 +196,6 @@ function M:fillResult0(room, peopleNum, result)
end
if infoList.seat == room.banker_seat then
ViewUtil:ErrorTip("显示庄家")
isZhuang.selectedIndex = 1
end
@ -210,7 +214,15 @@ function M:fillResult0(room, peopleNum, result)
huCardBtn.icon = string.format("ui://Main_Majiang/202_%d", infoList.win_card)
huCardBtn.visible = true
jiangMaList.visible = false
jiangMaList.visible = true
jiangMaList:SetVirtual()
jiangMaList.itemRenderer = function(index, obj)
obj.icon = string.format("ui://Main_Majiang/202_%d", infoJiangma[index + 1].card)
obj:GetController('bg').selectedIndex = infoJiangma[index + 1].score
obj:GetController('jing').selectedIndex = infoJiangma[index + 1].card == room.jing and 1 or 0
end
jiangMaList.numItems = #infoJiangma
jiangMaList.columnCount = #infoJiangma / 2
else
playerInfoComp:GetChild("text_huShow").text = ""
if not room.isZiMoHu and playInfo.self_user.account_id == result.active_player then

View File

@ -133,7 +133,6 @@ function M:OnEventSendCards(evt_data)
_room.jing = jing
self._cacheEvent:Enqueue(function()
_room.banker_seat = seat
-- print("========================fuzhijing")
for i = 1, #_room.player_list do
_room.player_list[i].hand_left_count = 13
_room.player_list[i].fz_list = {}
@ -201,7 +200,6 @@ function M:OnEventTurn(evt_data)
end
function M:OnEventFzTips(evt_data)
print("========================OnEventFzTips")
self._cacheEvent:Enqueue(function()
local tiplist = FZTipList.new()
local list = evt_data["tip_list"]
@ -288,7 +286,6 @@ function M:OnEventFzAction(evt_data)
end
function M:OnEventHu(evt_data)
-- print("===========================OnEventHu")
local cards = evt_data["card"]
local win_p = self._room:GetPlayerBySeat(evt_data["seat"])
local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"])

View File

@ -1,6 +1,7 @@
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local MJMainView = require("main.majiang.MJMainView")
local TableBG = require("Game.Data.TableBG")
local EXClearingView = import(".EXClearingView")
local TX_GameEvent = import(".GameEvent")
local HuTipView = import("main.majiang.HuTipView")
@ -8,6 +9,13 @@ local SettingView = import(".EXSettingView")
local PlayerInfoView = import(".EXPlayerInfoView")
local M = {}
local bg_config = {
{ id = 1, url = "extend/majiang/nancheng/bg/bg1", thumb = "ui://Extend_MJ_NanCheng/bg1" },
{ id = 2, url = "extend/majiang/nancheng/bg/bg2", thumb = "ui://Extend_MJ_NanCheng/bg2" },
{ id = 3, url = "extend/majiang/nancheng/bg/bg3", thumb = "ui://Extend_MJ_NanCheng/bg3" },
{ id = 4, url = "extend/majiang/nancheng/bg/bg4", thumb = "ui://Extend_MJ_NanCheng/bg4" }
}
--- Create a new ZZ_MainView
function M.new()
setmetatable(M, { __index = MJMainView })
@ -25,15 +33,19 @@ function M:InitView(url)
self._gps_style = 1
self._full = true
UIPackage.AddPackage("extend/majiang/lichuan/ui/Extend_MJ_LiChuan")
if self._room.room_config.people_num == 2 then
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num .. "_jiangxi")
else
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
-- if self._room.room_config.people_num == 2 then
-- MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
-- else
-- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
-- end
local use_custom_bg = true
MJMainView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num),
use_custom_bg)
if use_custom_bg then
TableBG.LoadTableBG(1, self._room.game_id, self._root_view, bg_config)
end
self._hu_tip = HuTipView.new(self)
self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人黎川麻将 ' .. room.score_times .. ''
self.selectLaiziBtn = self._view:GetChild('selectlaizi')
self.Laizi1Btn = self._view:GetChild('selectgang1')
self.Laizi2Btn = self._view:GetChild('selectgang2')
@ -46,9 +58,17 @@ function M:InitView(url)
--[[
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
--]]
local config = ExtendManager.GetExtendConfig(room.game_id)
local mode = config:GetGameInfo()
local gamePlay = mode:LoadConfigToDetail(json.encode(room.room_config.config))
self._view:GetChild('wanfa_text').text = gamePlay
self.jing = self._view:GetChild('jing')
self._state.onChanged:Add(function()
self:UpdatePlayerInfoView()
end)
local showNextCtr = self._view:GetController('showNext')
local ShowNextConfrimCtr = self._view:GetController('showNextConfrim')
local showNextList = self._view:GetChild('list_showNext')
@ -84,7 +104,6 @@ function M:InitView(url)
showNextList.selectedIndex = -1
self._showNextName = nil
end)
if self._room.room_config.people_num == 2 then
local btn_closeRoom = self._view:GetChild("btn_setting")
self._view:GetChild('btn_closeRoom').onClick:Set(function()
@ -126,7 +145,6 @@ function M:InitView(url)
local settingView = SettingView.new(self)
settingView:Show()
end))
end
--------
self:PlayerChangeLineState()
@ -185,13 +203,8 @@ function M:IsShowGangZi(btn, isShow)
end
function M:UpdateRound()
if self._room.room_config.people_num == 2 then
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
self._room.room_config.round)
else
self._view:GetChild("tex_round1").text = self._room.curren_round
self._view:GetChild("tex_round2").text = self._room.room_config.round
end
end
function M:ShowJing()
@ -211,12 +224,24 @@ function M:InitPlayerInfoView()
self._player_info = {}
local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild("player_info" .. i)
local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
tem.visible = false
end
end
function M:UpdatePlayerInfoView()
self._player_info = {}
local _player_info = self._player_info
local list = self._room.player_list
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
_player_info[i]:FillData(list[i])
end
end
function M:NewMJPlayerCardInfoView(view, index)
if index == 1 then
return MJPlayerSelfCardInfoView.new(view, self)
@ -356,7 +381,7 @@ function M:EventInit()
local player = _room:GetPlayerBySeat(win_seat)
if win_seat ~= _room.self_player.seat then
url = "ui://Main_Majiang/别人胡"
pNode = info._mask_liangpai
pNode = info._view
elseif win_seat == _room.self_player.seat then
url = "ui://Main_Majiang/自己胡牌"
pNode = self._view
@ -443,16 +468,16 @@ function M:EventInit()
local liuju = result.liuju
local data = result.info_list
local niao = result.niao
if liuju then
local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
self._view:AddChild(le)
le:Center()
le:GetTransition("t0"):Play()
coroutine.start(function()
coroutine.wait(1)
le:Dispose()
end)
end
-- if liuju then
-- local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
-- self._view:AddChild(le)
-- le:Center()
-- le:GetTransition("t0"):Play()
-- coroutine.start(function()
-- coroutine.wait(1)
-- le:Dispose()
-- end)
-- end
self:RemoveCursor()
if self._clearingView == nil then
self._clearingView = EXClearingView.new(self._root_view)
@ -496,7 +521,7 @@ function M:EventInit()
self._clearingView = nil
end)
end
self._player_card_info[1]:ShowHuTip()
-- self._player_card_info[1]:ShowHuTip()
end)
_gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...)
@ -563,59 +588,119 @@ function M:OutCard(card)
end
end
-- function M:__FangziTip(tip, weight)
-- printlog("__FangziTip")
-- local _gamectr = self._gamectr
-- local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips")
-- _chipeng_tip:GetController("hide_bg").selectedIndex = 1
-- self._chipeng_tip = _chipeng_tip
-- local p = self._room.self_player
-- -- self._player_card_info[self:GetPos(p.seat)]
-- local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi")
-- _lit_fanzi:RemoveChildrenToPool()
-- local _tlist = table.keys(tip.tip_map_type)
-- printlog(tip.tip_map_type)
-- pt(_tlist)
-- local tip_hu = false
-- local count = #_tlist
-- table.sort(_tlist)
-- local isHu = false
-- for k = 1, #_tlist do
-- local td = tip.tip_map_type[_tlist[k]][1]
-- local url = "ui://Main_Majiang/Btn_fztip"
-- local td_weight = td.weight
-- if td_weight == 16 then td_weight = 8 end
-- if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end
-- local btn_t = _lit_fanzi:AddItemFromPool(url)
-- btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
-- btn_t.data = { tip, td }
-- btn_t.onClick:Add(self.__TipAction, self)
-- end
-- -- if not (tonumber(weight) >= 16) then
-- local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- -- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
-- _btn_pass.onClick:Set(function()
-- if tonumber(weight) >= 8 then
-- local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel)
-- guo_msg.onOk:Add(function()
-- _gamectr:SendAction(0)
-- _chipeng_tip:Dispose()
-- self._chipeng_tip = nil
-- guo_msg:Close()
-- end)
-- guo_msg:Show()
-- else
-- _gamectr:SendAction(0)
-- _chipeng_tip:Dispose()
-- self._chipeng_tip = nil
-- end
-- end)
-- -- end
-- self._view:AddChild(_chipeng_tip)
-- _chipeng_tip:Center()
-- end
function M:__FangziTip(tip, weight)
print("========================OnEventFzTips2", tip, weight)
printlog("__FangziTip")
local _gamectr = self._gamectr
local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips")
_chipeng_tip:GetController("hide_bg").selectedIndex = 1
self._chipeng_tip = _chipeng_tip
local p = self._room.self_player
-- self._player_card_info[self:GetPos(p.seat)]
local info = self._player_card_info[1]
local _chipeng_tip = info._view_FZTips
local _ctr_tips = info._ctr_tip
local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi")
_lit_fanzi:RemoveChildrenToPool()
local _tlist = table.keys(tip.tip_map_type)
printlog(tip.tip_map_type)
pt(_tlist)
local tip_hu = false
local count = #_tlist
table.sort(_tlist)
local isHu = false
for k = 1, #_tlist do
local td = tip.tip_map_type[_tlist[k]][1]
local url = "ui://Main_Majiang/Btn_fztip"
local td_weight = td.weight
if td_weight == 16 then td_weight = 8 end
if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end
local btn_t = _lit_fanzi:AddItemFromPool(url)
btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
btn_t.data = { tip, td }
btn_t.onClick:Add(self.__TipAction, self)
end
-- if not (tonumber(weight) >= 16) then
local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
_btn_pass.onClick:Set(function()
if tonumber(weight) >= 8 then
local _lit_fanzi = _chipeng_tip:GetChild("list")
_lit_fanzi:SetVirtual()
local _tlist = tip.tip_map_id
_lit_fanzi.itemRenderer = function(index, obj)
local type = obj:GetController('type')
if index == tip.tip_num then
type.selectedIndex = 0
obj.onClick:Set(function()
local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel)
guo_msg.onOk:Add(function()
_gamectr:SendAction(0)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
_ctr_tips.selectedIndex = 0
guo_msg:Close()
end)
guo_msg:Show()
else
_gamectr:SendAction(0)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
end
end)
-- end
self._view:AddChild(_chipeng_tip)
_chipeng_tip:Center()
else
index = index + 1
if _tlist[index].type == FZType.HU then
type.selectedIndex = 4
obj:GetChild('btn_Card1').icon = string.format('ui://Main_Majiang/202_%d', _tlist[index].card)
elseif _tlist[index].type == FZType.Chi then
type.selectedIndex = FZType.Chi
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].opcard[i])
end
elseif _tlist[index].type == FZType.Peng then
type.selectedIndex = FZType.Peng
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
else
for i = 1, 4 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
type.selectedIndex = FZType.Gang
if _tlist[index].type == FZType.Gang_An then
obj:GetChild('btn_Card4').icon = 'ui://Main_Majiang/202_00'
end
end
obj.onClick:Set(function()
_gamectr:SendAction(_tlist[index].id)
_ctr_tips.selectedIndex = 0
end)
end
end
_ctr_tips.selectedIndex = 1
_lit_fanzi.numItems = tip.tip_num + 1
end
function M:__TipAction(context)
@ -722,7 +807,7 @@ function M:OnFangziAction(...)
end
effect.touchable = false
effect:GetTransition("t2"):Play()
pNode:AddChild(effect)
-- pNode:AddChild(effect)
coroutine.start(function()
coroutine.wait(0.3)
self._popEvent = true

View File

@ -17,14 +17,7 @@ function M.new(view, mainView)
end
function M:init()
if self._main_view._room.room_config.people_num ~= 2 then
PlayerInfoView.init(self)
self._tex_score = self._view:GetChild("info"):GetChild("tex_score1")
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2")
self._ct_score = self._view:GetChild("info"):GetController("score")
else
PlayerInfoView_copy.init(self)
end
end
function M:ShowInteraction(type, str)
@ -57,12 +50,7 @@ function M:UpdateRemainCard(card_num, hide)
end
function M:FillData(player)
if self._main_view._room.room_config.people_num == 2 then
PlayerInfoView_copy.FillData(self, player)
else
PlayerInfoView.FillData(self, player)
self:UpdateScore(player.total_score)
end
end
function M:UpdateScore()

View File

@ -1,8 +1,7 @@
local EXTEND_MODEL_NAME = ...
local EXGameInfo = import(".EXGameInfo")
local EXMainView = import(".EXMainView_jaingxi")
-- local EXMainView = import(".EXMainView")
local EXMainView = import(".EXMainView")
local EXGameController = import(".EXGameController")
local EXRoomConfig = import(".EXRoomConfig")
local EXPlayBackView = import(".EXPlayBackView")

View File

@ -1,5 +1,5 @@
local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local CardCheck = import(".CardCheck")
local M = {}
@ -15,199 +15,197 @@ function M.new(view, mainView)
return self
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)
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
end
self._mainView._hu_tip:FillData(tingList)
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)
-- 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
-- end
-- self._mainView._hu_tip:FillData(tingList)
-- end
function M:UpdateHandCard(getcard, mp)
print("====================================UpdateHandCard1", mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList
-- 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
print("====================================UpdateHandCard3")
local card_list = DataManager.CurrenRoom.self_player.card_list
-- self:ShowHuTip(card_list)
if getcard then
self._out_card = true
local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
-- 记录需要标记听牌提示的牌
local lst_mark = {}
local total_num = 0
for i = 1, #_carViewList do
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)
if #tingList > 0 then
local count = 0
for j = 1, #tingList do
count = count + self._mainView:CountCardLeftNum(tingList[j])
end
local tem = {}
tem.item = btn
tem.count = count
total_num = total_num + count
table.insert(lst_mark, tem)
end
table.insert(card_list, card)
end
table.sort(lst_mark, function(a, b)
return a.count > b.count
end)
-- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多'
local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false
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
else
tem.item:GetController("mark_ting").selectedIndex = 2
end
end
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
-- local card_list = DataManager.CurrenRoom.self_player.card_list
-- -- self:ShowHuTip(card_list)
-- if getcard then
-- self._out_card = true
-- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
-- -- 记录需要标记听牌提示的牌
-- local lst_mark = {}
-- local total_num = 0
-- for i = 1, #_carViewList do
-- 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)
-- if #tingList > 0 then
-- local count = 0
-- for j = 1, #tingList do
-- count = count + self._mainView:CountCardLeftNum(tingList[j])
-- end
-- local tem = {}
-- tem.item = btn
-- tem.count = count
-- total_num = total_num + count
-- table.insert(lst_mark, tem)
-- end
-- table.insert(card_list, card)
-- end
-- table.sort(lst_mark, function(a, b)
-- return a.count > b.count
-- end)
-- -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多'
-- local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false
-- 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
-- else
-- tem.item:GetController("mark_ting").selectedIndex = 2
-- end
-- end
-- 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)
-- print("==========================__OnClickHandCard")
local button = context.sender
local _carViewList = self._carViewList
local refresh = true
local card_list = {}
for i = 1, #_carViewList do
local btn = _carViewList[i].card
local card = self:GetCard(btn)
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
if not btn.selected then
table.insert(card_list, card)
end
end
-- function M:__OnClickHandCard(context)
-- local button = context.sender
-- local _carViewList = self._carViewList
-- local refresh = true
-- local card_list = {}
-- for i = 1, #_carViewList do
-- local btn = _carViewList[i].card
-- local card = self:GetCard(btn)
-- 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
-- if not btn.selected then
-- table.insert(card_list, card)
-- end
-- end
if self._out_card then
-- self:ShowHuTip(card_list)
end
-- if self._out_card then
-- -- self:ShowHuTip(card_list)
-- 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
-- -- 标记出牌
-- 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
-- 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:__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)
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
local button = context.sender
-- function M:__OnDragEnd(context)
-- 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
-- --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)
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
-- -- -- 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)
-- 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
-- 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
function M:Clear(bskip)
MJPlayerSelfCardInfoView.Clear(self)
--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.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
-- 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
for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose()
end
self._carViewList = {}
-- for i = 1, #self._carViewList do
-- self._carViewList[i].card:Dispose()
-- end
-- self._carViewList = {}
end
return M