dezhou_client/lua_probject/extend_project/extend/zipai/shihuka/EXMainView.lua

1073 lines
39 KiB
Lua

local SettingView = import('.main.ZPSettingView')
local PlayerSelfCardInfoView = import('.PlayerSelfCardInfoView')
local PlayerCardInfoView = import('.PlayerCardInfoView')
local ZPMainView = import('.main.ZPMainView')
local GameEvent = import('.RunBeard_GameEvent')
local RunBeard_ResultView = import('.RunBeard_ResultView')
local M = {}
local Fix_Msg_Chat = {
'在搞么的,出牌撒',
'又掉线哒!',
'和你打牌太有味了',
'人呢?还搞不搞滴',
'哈哈,对不住了',
'稍等哈哈,马上就来',
'不要走,决战到天亮',
'牌打得不错嘛!',
'今朝这个方位硬是不好',
'不好意思临时有事,申请解散!'
}
--- Create a new ZZ_MainView
function M.new()
setmetatable(M, {__index = ZPMainView})
local self = setmetatable({}, {__index = M})
self.class = 'RunBeard_MainView'
self._full = true
self:init()
return self
end
function M:getCardItem(card_1, card_2)
if self._room.change_card_display ~= nil then
return card_1 .. self._room.change_card_display .. card_2
else
return card_1 .. '2_' .. card_2
end
end
function M:InitView(url)
local _room = self._room
self.Fix_Msg_Chat = Fix_Msg_Chat
ViewUtil.PlayMuisc('ChangDe_ZP', 'extend/zipai/shihuka/sound/bg.mp3')
UIPackage.AddPackage('extend/zipai/shihuka/ui/Extend_Poker_ShiHuKa')
ZPMainView.InitView(self, 'ui://Main_RunBeard/Main_' .. _room.room_config.people_num, false, false, 1.2, 15)
self:PlayerChangeLineState()
SettingView.onEXMainCallback = handler(self, self.UpdateCardDisplay)
SettingView.onUpdataCardSizeCallback = handler(self, self.UpdateCardSize)
for i = 1, #_room.player_list do
local p = _room.player_list[i]
local head = self._player_info[self:GetPos(p.seat)]
if head._tex_score then
head._tex_score.visible = true
end
head:UpdateScore()
end
if _room.playing or _room.curren_round > 0 then
self:ReloadRoom()
end
self._view:GetController('jushu').selectedIndex = 1
self:setBtn()
end
function M:setBtn()
local rightpanel = self._view:GetChild('right_panel')
local btn_rule = rightpanel:GetChild('btn_log')
local gcm_chat = self._view:GetChild('gcm_chat')
local _btn_chat = gcm_chat:GetChild('n1')
_btn_chat:GetChild('icon').icon = 'ui://Main_RunBeard/chat_img'
local btn_record = gcm_chat:GetChild('btn_record')
btn_record:GetChild('icon').icon = 'ui://Main_RunBeard/yuyin_img'
if btn_rule ~= nil then
btn_rule.onClick:Set(
function()
if self.RuleView == nil or self.RuleView._is_destroy then
self.RuleView = RoomInfoView.new(self._room)
end
self.RuleView:Show()
end
)
end
local btn_setting = self._view:GetChild('btn_setting')
btn_setting.onClick:Set(
function()
local _settingView = self:NewSettingView()
_settingView.stateIndex = (self._room.curren_round >= 1 and self._allow_dissmiss) and 2 or 1
_settingView.cd_time = self.dismiss_room_cd_time
_settingView:Show()
local room = DataManager.CurrenRoom
_settingView.onCallback:Add(
function(context)
local _gamectr = ControllerManager.GetController(GameController)
if (room.CurnrenState == StateType.Ready) then
_gamectr:LevelRoom(
function(response)
if (response.ReturnCode == 0) then
ViewManager.ChangeView(ViewManager.View_Lobby)
GameApplication.Instance:ShowTips('房间已解散!')
end
end
)
else
_gamectr:AskDismissRoom(
function(res)
ViewUtil.ErrorTip(res.ReturnCode, '')
end
)
end
end
)
end
)
local tex_roomid = rightpanel:GetChild('tex_roomid')
tex_roomid.text = self._room.room_id
if self._room.room_config.isHidden and self._room.room_config.isHidden == 1 then
tex_roomid.text = "000000"
end
end
function M:NewPlayerCardInfoView(view, index)
if index == 1 then
return PlayerSelfCardInfoView.new(view, self)
end
return PlayerCardInfoView.new(view, self)
end
function M:closeTipOnTuoguan()
if self._clearingView ~= nil then
self._clearingView:Close()
end
self:__CloseTip()
end
function M:EventInit()
MainView.EventInit(self)
local _room = self._room
local _view = self._view
local _player_info = self._player_info
local _gamectr = self._gamectr
printlog("jefe EventInit===》》》》",GameEvent.EventXiPai)
_gamectr:AddEventListener(GameEvent.EventXiPai,function( ... )
local arg = {...}
local currentPlayer1=arg[1]
local currentPlayer2=arg[2]
printlog("jefe AddEventListener===》》》》",arg)
self._popEvent = false
if ( currentPlayer1 ) then
local xipaiCB=function ()
self._popEvent = true
end
self:PlayXiPai(xipaiCB)
end
if ( currentPlayer2 ) then
--self._popEvent = false
local xipaiCB2=function ()
self._popEvent = true
end
self:PlayXiPai1(xipaiCB2)
end
end)
_gamectr:AddEventListener(
GameEvent.SendCards,
function(...)
self._popEvent = false
self._leftcard = 1
self._leftcard = 1
local rightpanel = self._view:GetChild('right_panel')
local tex_round = rightpanel:GetChild('tex_round')
if tex_round ~= nil then
tex_round.text = '' .. _room.curren_round .. ''
end
self._view:GetChild('tex_round').text = '' .. _room.curren_round .. '/' .. _room.room_config.round .. ''
self._state.selectedIndex = 1
self:closeTipOnTuoguan()
local list = _room.player_list
for i = 1, #list do
local p = list[i]
p.hu_xi = 0
local _info = self._player_card_info[self:GetPos(p.seat)]
_info:SetPlayer(p)
local info = self._player_info[self:GetPos(p.seat)]
info:FillData(p)
info:MarkBank(p.seat == _room.banker_seat)
info:Ready(false)
info._view:GetController('huxi').selectedIndex = 1
info._view:GetChild('huxi').text = p.hu_xi
info._view:GetController('zhanji').selectedIndex = 0
if _room.hpOnOff == 1 or _room:checkHpNonnegative() then
if p.total_hp == nil then
p.total_hp = 0
end
info._view:GetController('zhanji').selectedIndex = 1
info._view:GetChild('tex_jifen').text = d2ad(p.total_hp)
end
end
local card_info = self._player_card_info[1]
card_info:UpdateIsOnClick(false)
card_info:InitHandCard(true)
end
)
_gamectr:AddEventListener(
GameEvent.GetCard,
function(...)
local arg = {...}
local seat = arg[1]
local card = arg[2]
local _leftcard = arg[3]
self._left_time = 15
self._tex_LeftCard.text = '剩余 ' .. _leftcard .. ' 张牌'
local info = self._player_card_info[self:GetPos(seat)]
info:UpdateOutCardList(card, true, true, self:GetPos(seat))
if card ~= 0 then
local p = _room:GetPlayerBySeat(seat)
self:PlaySound(p.self_user.sex, 'F_' .. card)
else
self._popEvent = false
coroutine.start(
function()
coroutine.wait(0.5)
self._popEvent = true
info:ClearOutCard()
end
)
end
end
)
_gamectr:AddEventListener(
GameEvent.AddCard,
function(...)
local arg = {...}
local seat = arg[1]
local card = arg[2]
self._popEvent = false
local info = self._player_card_info[self:GetPos(seat)]
coroutine.start(
function()
coroutine.wait(0.5)
if seat == self._room.self_player.seat then
info:InitHandCard(false)
end
info:ClearOutCard()
self._popEvent = true
end
)
end
)
_gamectr:AddEventListener(
GameEvent.EventTurn,
function(...)
local arg = {...}
local seat = arg[1]
local list = _room.player_list
local readyNum = 0
for i = 1, #list do
local p = list[i]
local info = self._player_info[self:GetPos(p.seat)]
info._view:GetController('time').selectedIndex = 0
end
local info = self._player_info[self:GetPos(seat)]
info._view:GetController('time').selectedIndex = 1
end
)
_gamectr:AddEventListener(
GameEvent.OutHint,
function(...)
_room.curren_outcard_seat = _room.self_player.seat
printlog("jefe OutHint view>>>>",card)
coroutine.start(
function()
coroutine.wait(0.5)
local info = self._player_card_info[self:GetPos(_room.self_player.seat)]
info:ChuPaiTiShi()
end
)
end
)
_gamectr:AddEventListener(
GameEvent.FangWei,
function(...)
local arg = {...}
local seat = arg[1]
local card = arg[2]
--self:__CloseTip()
_room.curren_outcard_seat = _room.self_player.seat
local _player_card_info = self._player_card_info
-- local seat = evt_data["seat"]
--local card = evt_data["card"]
printlog("jefe FangWei view>>>>")
local p = self._room:GetPlayerBySeat(seat)
local info = self._player_card_info[self:GetPos(seat)]
local fangwei_msg = MsgWindow.new(self._root_view, '放偎之后这局将不能再吃碰,是否确定', MsgWindow.MsgMode.OkAndCancel)
local removeOutcard = self._player_card_info[1]
fangwei_msg.onOk:Add(
function()
local _gamectr = ControllerManager.GetController(GameController)
if _gamectr then
_gamectr:SendFangPao(card)
end
-- 判断是否对方有偎
-- local p = self._room:GetPlayerBySeat(seat)
--DispatchEvent(self._dispatcher,RB_GameEvent.OutCard, p,card)
end
)
fangwei_msg.onCancel:Add(
function(...)
--
self:__CloseTip()
if seat == self._room.self_player.seat then
if seat == self._room.self_player.seat then
info:InitHandCard(true)
end
end
end
)
fangwei_msg:Show()
end
)
_gamectr:AddEventListener(
GameEvent.OutCard,
function(...)
self:__CloseTip()
self._left_time = 0
local arg = {...}
local p = arg[1]
local card = arg[2]
local seat = p.seat
local info = self._player_card_info[self:GetPos(seat)]
self:PlaySound(p.self_user.sex, 'F_' .. card)
if seat == self._room.self_player.seat then
_room.curren_outcard_seat = -1
info:DeleteHandCard(card)
info:UpdateIsOnClick(true)
info:SendChangeCard()
info:ChuPaiTiShi()
end
local list = _room.player_list
for i = 1, #list do
local p = list[i]
local info = self._player_info[self:GetPos(p.seat)]
info._view:GetController('time').selectedIndex = 0
end
info:UpdateOutCardList(card, true, false, self:GetPos(seat))
if self._leftcard == 1 then
self._leftcard = 0
for i = 1, #_room.player_list do
local p = _room.player_list[i]
local card_info = self._player_card_info[self:GetPos(p.seat)]
card_info:UpdateFzList(p.fz_list, false, p.seat)
end
end
end
)
_gamectr:AddEventListener(
GameEvent.QiCard,
function(...)
self:__CloseTip()
self._popEvent = false
self._left_time = 0
local arg = {...}
local seat = arg[1]
local card = arg[2]
local p = _room:GetPlayerBySeat(seat)
local info = self._player_card_info[self:GetPos(seat)]
info:PlayingOutCardAnima(p.DiceCard)
p.DiceCard = 0
info:UpdateQiPai(p.outcard_list, true, seat)
self._popEvent = true
end
)
_gamectr:AddEventListener(
GameEvent.FZTips,
function(...)
local arg = {...}
local _tip = arg[1]
local _uid = arg[2]
local _fptype = arg[3]
self:__FangziTip(_tip, _uid,_fptype)
end
)
_gamectr:AddEventListener(GameEvent.FangziAction, handler(self, self.OnFangziAction))
_gamectr:AddEventListener(
GameEvent.ZPHuCard,
function(...)
self._left_time = 0
self:__CloseTip()
self._popEvent = false
local arg = {...}
local w = arg[1]
local l = arg[2]
local cards = arg[3]
local info = self._player_card_info[self:GetPos(w)]
-- info:UpdateHandCard()
local url = 'ui://Extend_Poker_ShiHuKa/别人胡'
local pNode = info._mask_liangpai
local player = _room:GetPlayerBySeat(w)
if w == _room.self_player.seat then
url = 'ui://Extend_Poker_ShiHuKa/自己胡牌'
pNode = self._view
end
self:PlaySound(player.self_user.sex, 'F_Hu')
local he = UIPackage.CreateObjectFromURL(url)
he:GetTransition('t2'):Play()
if w == _room.self_player.seat then
he:Center()
end
pNode:AddChild(he)
coroutine.start(
function()
coroutine.wait(0.7)
he:Dispose()
self._popEvent = true
end
)
end
)
_gamectr:AddEventListener(
GameEvent.ZPResult1,
function(...)
self._popEvent = false
self._left_time = 0
local arg = {...}
local result = arg[1]
local liuju = result.liuju
local data = result.info_list
local x = {}
self._hu_tip:FillData(x)
self:__CloseTip()
if self._clearingView == nil then
if liuju == true then
self._clearingView = RunBeard_ResultView.new(self._view, 1)
else
self._clearingView = RunBeard_ResultView.new(self._view)
end
end
coroutine.start(
function()
coroutine.wait(0.5)
-- if self._clearingView._is_destroy then return end
self._clearingView:Show()
if _room.curren_round ~= _room.room_config.round then
for i = 1, #data do
local p = _room:GetPlayerBySeat(data[i].seat)
local card_info = self._player_card_info[self:GetPos(p.seat)]
local info = self._player_info[self:GetPos(p.seat)]
p.total_score = data[i].total_score
p.cur_hp = data[i]['cur_hp'] or 0
p.total_hp = data[i]['total_hp'] or 0
if data[i]['hp_info'] then
p.cur_hp = data[i].hp_info.cur_hp
p.total_hp = data[i].hp_info.total_hp == nil and 0 or data[i].hp_info.total_hp
info._view:GetController('zhanji').selectedIndex = 0
if _room.hpOnOff == 1 or _room:checkHpNonnegative() then
info._view:GetController('zhanji').selectedIndex = 1
info._view:GetChild('tex_jifen').text = d2ad(p.total_hp)
end
end
card_info:Clear()
info:UpdateScore()
end
local list = _room.player_list
for i = 1, #list do
local p = list[i]
local info = self._player_info[self:GetPos(p.seat)]
info._view:GetController('time').selectedIndex = 0
end
for i = 1, #_room.player_list do
_room.self_player.handcard_list = {}
_room.player_list[i].DiceCard = nil
_room.player_list[i].hand_left_count = 20
_room.player_list[i].fz_list = {}
_room.player_list[i].card_list = {}
_room.player_list[i].outcard_list = {}
_room.player_list[i].hu_xi = 0
end
end
self._popEvent = true
end
)
if _room.curren_round ~= _room.room_config.round then
self._clearingView:InitData(
0,
_room,
result,
nil,
function(...)
self._state.selectedIndex = 2
self._clearingView = nil
end
)
end
end
)
_gamectr:AddEventListener(
GameEvent.ZPResult2,
function(...)
self._left_time = 0
local arg = {...}
local total_result = arg[2]
local result = arg[1]
local over = arg[3]
local x = {}
self._hu_tip:FillData(x)
self:__CloseTip()
self:UnmarkSelfTuoguan()
self._clearingView = RunBeard_ResultView.new()
coroutine.start(
function()
coroutine.wait(0.5)
self._clearingView:Show()
end
)
self._clearingView:InitData(over, _room, result, total_result)
ControllerManager.ChangeController(LoddyController)
end
)
end
function M:OutCard(card_item)
local _gamectr = ControllerManager.GetController(GameController)
self._room.curren_outcard_seat = -1
_gamectr:SendOutCard(card_item)
end
--改变牌队形
function M:ChangeCards(list)
local _gamectr = ControllerManager.GetController(GameController)
if _gamectr then
_gamectr:SendChangeCards(list)
end
end
function M:__FangziTip(tip, _uid,fptype)
local _gamectr = self._gamectr
local _chipeng_tip = UIPackage.CreateObject('Main_RunBeard', 'Gcm_action_tips')
self._chipeng_tip = _chipeng_tip
local p = self._room.self_player
printlog("jefe __FangziTip>>>>",_uid)
local _lit_fanzi = _chipeng_tip:GetChild('lit_fanzi')
_lit_fanzi:RemoveChildrenToPool()
local _tlist = table.keys(tip.tip_map_type)
local tip_hu = false
local count = #_tlist
for k = 1, #_tlist do
local td = tip.tip_map_type[_tlist[k]][1]
if td.type == 8 then
tip_hu = true
end
end
for k = 1, #_tlist do
local td = tip.tip_map_type[_tlist[k]][1]
local url = 'ui://Main_RunBeard/Btn_fztip'
local btn_t = _lit_fanzi:AddItemFromPool(url)
btn_t.icon = 'ui://Main_RunBeard/newop_' .. td.type
btn_t.data = {tip, td, tip_hu}
btn_t.onClick:Set(self.__TipAction, self)
end
if p.hand_left_count ~= 0 then
local _btn_pass = _lit_fanzi:AddItemFromPool('ui://Main_RunBeard/Btn_pass_new')
_btn_pass.onClick:Set(
function()
if tip_hu then
local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel)
guo_msg.onOk:Add(
function()
_gamectr:SendAction(_uid)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
guo_msg:Close()
end
)
guo_msg:Show()
else
_gamectr:SendAction(_uid)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
end
end
)
end
--禁止放跑
if fptype == 1 and tip_hu == false then
_gamectr:SendAction(_uid)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
else
self._view:AddChild(_chipeng_tip)
_chipeng_tip:Center()
_chipeng_tip.x = _chipeng_tip.x + 200
_chipeng_tip.y = _chipeng_tip.y - 50
end
end
function M:__TipAction(context)
local data = context.sender.data
local _gamectr = self._gamectr
local tip = data[1]
local td = data[2]
local tip_hu = data[3]
local list = tip.tip_map_type[td.weight]
if (#list > 1) or td.type == 1 then
self:_ChiView(
list,
tip_hu,
function(id)
if tip_hu and td.type ~= 8 then
local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel)
guo_msg.onOk:Add(
function()
_gamectr:SendAction(id)
guo_msg:Close()
self:__CloseTip()
local info = self._player_card_info[1]
info:UpdateIsOnClick(false)
end
)
guo_msg:Show()
else
_gamectr:SendAction(id)
self:__CloseTip()
local info = self._player_card_info[1]
info:UpdateIsOnClick(false)
end
end
)
--self._chipeng_tip.visible = false
return
end
if tip_hu and td.type ~= 8 then
local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel)
guo_msg.onOk:Add(
function()
_gamectr:SendAction(td.id)
guo_msg:Close()
local info = self._player_card_info[1]
info:UpdateIsOnClick(false)
if (self._chipeng_tip == nil) then
return
end
self._chipeng_tip:Dispose()
self._chipeng_tip = nil
end
)
guo_msg:Show()
else
_gamectr:SendAction(td.id)
local info = self._player_card_info[1]
info:UpdateIsOnClick(false)
if (self._chipeng_tip == nil) then
return
end
self._chipeng_tip:Dispose()
self._chipeng_tip = nil
end
end
function M:_ChiView(tip_list, tip_hu, callback)
local _pop_tip_choice = UIPackage.CreateObject('Main_RunBeard', 'Pop_tip_choice')
local list_choose = _pop_tip_choice:GetChild('Lst_choose')
_pop_tip_choice:GetChild('dibtn').onClick:Add(
function()
_pop_tip_choice:Dispose()
end
)
list_choose:RemoveChildrenToPool()
for i = 1, #tip_list do
if tip_list[i].weight ~= 4 then
local item_choose = list_choose:AddItemFromPool()
item_choose:GetChild('card' .. 2).icon =
UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', tip_list[i].OpCard[1]))
item_choose:GetChild('card' .. 3).icon =
UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', tip_list[i].OpCard[2]))
item_choose:GetChild('card' .. 1).icon =
UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', tip_list[i].card))
item_choose.onClick:Add(
function()
for k = 1, list_choose.numChildren do
list_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0
end
item_choose:GetController('zhong').selectedIndex = 1
if tip_list[i].bi_list == nil then
callback(tip_list[i].id)
else
self.bilist = {}
self._chiid = tip_list[i].id
self:CheckRatioCard(tip_list[i].bi_list, 1, tip_list[i].card)
end
end
)
end
end
list_choose:ResizeToFit(#tip_list)
_pop_tip_choice:GetChild('di1').width = list_choose.width + 110
_pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, -100)
self._view:AddChild(_pop_tip_choice)
self._pop_tip_choice = _pop_tip_choice
end
function M:CheckRatioCard(_tiplist, index, chicard, _biid, list)
if _biid ~= nil then
self.bilist = {}
self.bilist[#self.bilist + 1] = _biid
end
if self._pop_tip_choice == nil then
-- statements
return
end
self._pop_tip_choice:GetController('bipai').selectedIndex = index
local Bilist_choose = self._pop_tip_choice:GetChild('Bi_Lst_choose' .. index)
Bilist_choose:RemoveChildrenToPool()
for i = 1, #_tiplist do
local item = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Comp_choose')
local item_choose = Bilist_choose:AddChild(item)
item_choose:GetChild('card' .. 2).icon =
UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', _tiplist[i].opcard[1]))
item_choose:GetChild('card' .. 3).icon =
UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', _tiplist[i].opcard[2]))
item_choose:GetChild('card' .. 1).icon =
UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', chicard))
item_choose:GetController('zhong').selectedIndex = 0
item_choose.onClick:Add(
function()
for k = 1, Bilist_choose.numChildren do
Bilist_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0
end
item_choose:GetController('zhong').selectedIndex = 1
if _tiplist[i].bi_list == nil then
if index == 1 then
self.bilist = {}
end
self.bilist[#self.bilist + 1] = i - 1
if tip_hu then
local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel)
guo_msg.onOk:Add(
function()
self._gamectr:SendAction(self._chiid, self.bilist)
guo_msg:Close()
self:__CloseTip()
local info = self._player_card_info[1]
info:UpdateIsOnClick(false)
end
)
guo_msg:Show()
else
self._gamectr:SendAction(self._chiid, self.bilist)
self:__CloseTip()
local info = self._player_card_info[1]
info:UpdateIsOnClick(false)
end
else
self:CheckRatioCard(_tiplist[i].bi_list, 2, chicard, i - 1, #_tiplist)
end
end
)
end
Bilist_choose:ResizeToFit(#_tiplist)
self._pop_tip_choice:GetChild('di' .. index + 1).width = Bilist_choose.width + 110
end
-- lua table 深拷贝
function M:deepcopy(object)
local lookup_table = {}
local function _copy(object)
if type(object) ~= 'table' then
return object
elseif lookup_table[object] then
return lookup_table[object]
end
local new_table = {}
lookup_table[object] = new_table
for index, value in pairs(object) do
new_table[_copy(index)] = _copy(value)
end
return setmetatable(new_table, getmetatable(object))
end
return _copy(object)
end
function M:OnFangziAction(...)
local arg = {...}
local _player_card_info = self._player_card_info
local fz = arg[1]
local player = arg[2]
local num = arg[3]
if fz.type == RB_FZType.Peng or fz.type == RB_FZType.Chi or fz.type == RB_FZType.Bi then
self:__CloseTip()
end
if (player == self._room.self_player) then
local info = _player_card_info[self:GetPos(player.seat)]
info:UpdateIsOnClick(false)
end
self._popEvent = false
local info = _player_card_info[self:GetPos(player.seat)]
info:UpdateFzList(player.fz_list, true, player.seat) --更新放子数组
if (player == self._room.self_player) then
if fz.type == RB_FZType.Chi then
for i = 1, #fz.opcard do
info:DeleteHandCard(fz.opcard[i])
end
elseif fz.type == RB_FZType.Bi then
for i = 1, #fz.opcard do
info:DeleteHandCard(fz.opcard[i])
end
info:DeleteHandCard(fz.card)
elseif fz.type == RB_FZType.Peng then
for i = 1, #fz.opcard do
info:DeleteHandCard(fz.opcard[i])
end
elseif fz.type == RB_FZType.Kan then
if #fz.opcard == 2 then
info:InitHandCard(false)
end
info:UpdateKan(fz.card)
elseif fz.type == RB_FZType.Wei then
for i = 1, #fz.opcard do
info:DeleteHandCard(fz.opcard[i])
end
elseif fz.type == RB_FZType.ChouWei then
for i = 1, #fz.opcard do
info:DeleteHandCard(fz.opcard[i])
end
elseif fz.type == RB_FZType.Pao then
if num > 0 then
for i = 1, #fz.opcard do
info:DeleteHandCard(fz.opcard[i])
end
end
elseif fz.type == RB_FZType.Ti then
if num > 0 then
for i = 1, #fz.opcard do
info:DeleteHandCard(fz.opcard[i])
end
end
end
coroutine.start(
function()
coroutine.wait(0.3)
if fz.type ~= RB_FZType.Kan then
info:SendChangeCard()
end
end
)
end
-- if false then
if fz.type ~= RB_FZType.Kan and fz.type ~= RB_FZType.Bi then
printlog("jefe self RB_FZType 2=======")
local info = _player_card_info[self:GetPos(player.seat)]
local pNode = info._mask_liangpai
local effect = UIPackage.CreateObject('Extend_Poker_ShiHuKa', 'FzEffect')
if fz.type == RB_FZType.Peng then
-- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "peng")
self:PlaySound(player.self_user.sex, 'F_Peng')
effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'peng')
elseif fz.type == RB_FZType.Chi then
-- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "chi")
self:PlaySound(player.self_user.sex, 'F_Chi')
effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'chi')
elseif fz.type == RB_FZType.Wei then
-- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "wei")
self:PlaySound(player.self_user.sex, 'F_GuoSao')
effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'wei')
elseif fz.type == RB_FZType.ChouWei then
-- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Extend_Poker_ShiHuKa", "chouwei")
self:PlaySound(player.self_user.sex, 'F_GuoSao')
effect:GetChild('icon1').icon = UIPackage.GetItemURL('Extend_Poker_ShiHuKa', 'chouwei')
elseif fz.type == RB_FZType.Pao then
-- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "pao")
self:PlaySound(player.self_user.sex, 'F_KaiDuo')
effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'pao')
elseif fz.type == RB_FZType.Ti then
self:PlaySound(player.self_user.sex, 'F_SaoChuan')
effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'ti')
-- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti")
end
effect.touchable = false
effect.x, effect.y = 0, 0
effect:GetTransition('t0'):Play()
pNode:AddChild(effect)
coroutine.start(
function()
coroutine.wait(1)
effect:Dispose()
end
)
end
if (player == self._room.self_player) then
coroutine.start(
function()
coroutine.wait(0.5)
local info = _player_card_info[self:GetPos(player.seat)]
info:ShowHuTip()
end
)
end
local removeOutcard = _player_card_info[self:GetPos(fz.from_seat)]
local p = self._room:GetPlayerBySeat(fz.from_seat)
if p.DiceCard ~= nil and fz.active_card == p.DiceCard then
removeOutcard:ClearOutCard()
p.DiceCard = nil
end
local list = self._room.player_list
for i = 1, #list do
local p = list[i]
local info = self._player_info[self:GetPos(p.seat)]
info._view:GetChild('huxi').text = p.hu_xi
end
self._popEvent = true
coroutine.start(
function()
coroutine.wait(0.3)
local info = _player_card_info[1]
info:UpdateIsOnClick(true)
end
)
end
function M:ReloadRoom()
local _gamectr = self._gamectr
local room = self._room
if not room.playing then
self._state.selectedIndex = 2
else
self._state.selectedIndex = 1
end
if room.discard == 0 then
self._leftcard = 1
else
self._leftcard = 0
end
for i = 1, #room.player_list do
local p = room.player_list[i]
if p.seat == room.banker_seat then
local head = self._player_info[self:GetPos(p.seat)]
head:MarkBank(true)
end
if p.ready then
self._player_info[self:GetPos(p.seat)]:Ready(true)
else
self._player_info[self:GetPos(p.seat)]:Ready(false)
end
if self._state.selectedIndex == 1 then
local info = self._player_info[self:GetPos(p.seat)]
info._view:GetController('huxi').selectedIndex = 1
info._view:GetChild('huxi').text = p.hu_xi
info._view:GetController('zhanji').selectedIndex = 0
if room.hpOnOff == 1 or room:checkHpNonnegative() then
if p.total_hp == nil then
p.total_hp = 0
end
info._view:GetController('zhanji').selectedIndex = 1
info._view:GetChild('tex_jifen').text = d2ad(p.total_hp)
end
end
local card_info = self._player_card_info[self:GetPos(p.seat)]
card_info:UpdateQiPai(p.outcard_list)
card_info:UpdateFzList(p.fz_list, false, p.seat)
if p.DiceCard ~= nil and p.DiceCard ~= 0 then
card_info:UpdateOutCardList(p.DiceCard)
end
if DataManager.CurrenRoom.curren_outcard_seat == p.seat then
local info = self._player_info[self:GetPos(p.seat)]
info._view:GetController('time').selectedIndex = 1
end
if p.seat == self._room.self_player.seat then
card_info:ChuPaiTiShi()
if
self._room.self_player.card_list ~= nil and
#self._room.self_player.handcard_list == #self._room.self_player.card_list
then
local _list = self:deepcopy(self._room.self_player.card_list)
local cards = {}
for i = 1, #_list do
cards[#cards + 1] = _list[i].card_item
end
table.sort(cards, ViewUtil.HandCardSort)
table.sort(self._room.self_player.handcard_list, ViewUtil.HandCardSort)
local isNot = false
for i = 1, #cards do
if cards[i] ~= self._room.self_player.handcard_list[i] then
isNot = true
end
end
if isNot == true then
card_info:InitHandCard(false)
else
card_info:UpdateHandCards(self._room.self_player.card_list)
end
else
card_info:InitHandCard(false)
end
-- card_info:ChuPaiTiShi()
card_info:ShowHuTip()
for i = 1, #p.fz_list do
if p.fz_list[i].type == RB_FZType.Kan then
card_info:UpdateKan(3, p.fz_list[i].card)
end
end
end
end
self._tex_LeftCard.text = '剩余 ' .. room.left_count .. ' 张牌'
local rightpanel = self._view:GetChild('right_panel')
local tex_round = rightpanel:GetChild('tex_round')
if tex_round ~= nil then
tex_round.text = '' .. room.curren_round .. ''
end
self._view:GetChild('tex_round').text = '' .. room.curren_round .. '/' .. room.room_config.round .. ''
end
function M:PlayChatSound(sex, chat_index)
local sex_path = ViewUtil.Sex_Chat[sex]
local path1 = string.format('extend/zipai/shihuka/sound/%s/chat_%s.mp3', sex_path, tostring(chat_index))
ViewUtil.PlaySound('ChangDe_ZP', path1)
end
function M:PlaySound(sex, path)
local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女
local sound_path = string.format('extend/zipai/shihuka/sound/%s/%s.mp3', sex_path, path)
ViewUtil.PlaySound('ChangDe_ZP', sound_path)
end
function M:__CloseTip()
if (self._chipeng_tip) then
self._chipeng_tip:Dispose()
self._chipeng_tip = nil
end
if (self._pop_tip_choice) then
self._pop_tip_choice:Dispose()
self._pop_tip_choice = nil
end
end
function M:Destroy()
ZPMainView.Destroy(self)
UIPackage.RemovePackage('extend/zipai/shihuka/ui/Extend_Poker_ShiHuKa')
end
return M