changhong_newclient/lua_probject/extend_project/extend/zipai/fulushou/EXGameInfo.lua

233 lines
6.2 KiB
Lua

local EXGameInfo = {}
local M = EXGameInfo
function EXGameInfo.new(blur_view)
setmetatable(M, { __index = IGameInfo })
local self = setmetatable({}, { __index = M })
self.class = 'EXGameInfo'
UIPackage.AddPackage('extend/zipai/fulushou/ui/Info_Poker_FuLuShou')
return self
end
function M:FillData()
printlog("jefe fulushou")
self._maxPlayer = 3 -- 默认玩家人数
self._roundChoice = 2 -- 回合选项数
self._config = UIPackage.CreateObjectFromURL('ui://Info_Poker_FuLuShou/Cgm_create_room')
if oldGameVersion == 1 then
self._config:GetController("xipai").selectedIndex = 0
end
if oldGameVersion == 2 then
self._config:GetController("xipai").selectedIndex = 1
self.xipaiValueText = self._config:GetChild('xipaifen')
self.xipaiValueText.text = 1
self.xipaiValue = 1
self.anchouValueText = self._config:GetChild('anchoufen')
self.anchouValueText.text = 1
self.anchouValue = 1
local btn_cr = self._config:GetChild('sdsrbtn')
btn_cr.onClick:Set(
function()
local gniv = GroupNumberInputView_Game.new(nil, function(num)
local value = limit
if otype == 1 then
value = value + ad2d(num)
elseif otype == -1 then
value = value - ad2d(num)
else
value = ad2d(num)
end
if value < 0 then
ViewUtil.ErrorTip(1, "输入数据异常!")
end
self.xipaiValueText.text = value / 100
self.xipaiValue = value / 100
end, 3, nil)
gniv:Show()
end
)
local btn_cr2 = self._config:GetChild('anchoubtn')
btn_cr2.onClick:Set(
function()
local gniv = GroupNumberInputView_Game.new(nil, function(num)
local value = limit
if otype == 1 then
value = value + ad2d(num)
elseif otype == -1 then
value = value - ad2d(num)
else
value = ad2d(num)
end
if value < 0 then
ViewUtil.ErrorTip(1, "输入数据异常!")
end
self.anchouValueText.text = value / 100
self.anchouValue = value / 100
end, 3, nil)
gniv:Show()
end
)
end
end
local _help_url = 'ui://Info_Poker_FuLuShou/Com_help'
function M:GetHelpUrl()
return _help_url
end
local _icon_url = "ui://Info_Poker_FuLuShou/icon"
function M:GetIconUrl()
return _icon_url
end
local _icon_url1 = "ui://Info_Poker_FuLuShou/icon1"
function M:GetIconUrl1()
return _icon_url1
end
--local _play_list = {"三人玩法","二人玩法"}
function M:GetPlayList()
--return _play_list
end
function M:SelectedConfigData()
local _config = self._config
local round = _config:GetController('round').selectedIndex == 0 and 1 or 2
local renshu = _config:GetController('play_list').selectedIndex + 2
local xuan_zhuang = _config:GetController('zhuangjia').selectedIndex
local piao = _config:GetController('piao').selectedIndex
local piao1 = false
local piao2 = false
local piao3 = false
local piao4 = false
if piao == 3 then
piao1 = _config:GetChild('pf1').selected and true or false
piao2 = _config:GetChild('pf2').selected and true or false
piao3 = _config:GetChild('pf3').selected and true or false
piao4 = _config:GetChild('pf4').selected and true or false
end
local fen_diejia = _config:GetController('fen').selectedIndex
local qing_zui_hu = _config:GetController('qinzuihu').selectedIndex
local gang_zhao_liu_xi = _config:GetChild('gangzhao').selected and true or false
local special_peng_peng_hu = _config:GetChild('pengpenghu').selected and true or false
local piao_fen = _config:GetController('piaofen').selectedIndex
local _data = {}
_data['opt'] = round -- 1 2 8局 16 局
_data['maxPlayers'] = renshu
_data['xuan_zhuang'] = xuan_zhuang
_data['piao'] = piao
_data['piao1'] = piao1
_data['piao2'] = piao2
_data['piao3'] = piao3
_data['piao4'] = piao4
_data['fen_diejia'] = fen_diejia
_data['qing_zui_hu'] = qing_zui_hu
_data['gang_zhao_liu_xi'] = gang_zhao_liu_xi
_data['special_peng_peng_hu'] = special_peng_peng_hu
if (piao_fen == 0) then
_data["piao_fen"] = 1
elseif (piao_fen == 1) then
_data["piao_fen"] = 2
elseif (piao_fen == 2) then
_data["piao_fen"] = 3
elseif (piao_fen == 3) then
_data["piao_fen"] = 5
end
local xi_pai = false
if oldGameVersion == 2 then
if _config:GetChild("xipai") then
xi_pai = _config:GetChild("xipai").selected
end
end
_data['xi_pai'] = xi_pai
local xi_pai_score = 0
local an_chou_score = 0
if oldGameVersion == 2 then
xi_pai_score = self.xipaiValue
an_chou_score = self.anchouValue
end
_data['xi_pai_score'] = xi_pai_score * 100
_data['an_chou_score'] = an_chou_score * 100
return _data
end
function M:LoadConfigData(data)
local _config = self._config
_config:GetController('play_list').selectedIndex = data.maxPlayers - 2
_config:GetController('round').selectedIndex = data.opt == 1 and 0 or 1
_config:GetController('zhuangjia').selectedIndex = data.xuan_zhuang
_config:GetController('piao').selectedIndex = data.piao
_config:GetChild('pf1').selected = data.piao1
_config:GetChild('pf2').selected = data.piao2
_config:GetChild('pf3').selected = data.piao3
_config:GetChild('pf4').selected = data.piao4
if (data.piao_fen == 1) then
_config:GetController('piaofen').selectedIndex = 0
elseif (data.piao_fen == 2) then
_config:GetController('piaofen').selectedIndex = 1
elseif (data.piao_fen == 3) then
_config:GetController('piaofen').selectedIndex = 2
elseif (data.piao_fen == 5) then
_config:GetController('piaofen').selectedIndex = 3
end
_config:GetController('fen').selectedIndex = data.fen_diejia
_config:GetController('qinzuihu').selectedIndex = data.qing_zui_hu
_config:GetChild('gangzhao').selected = data.gang_zhao_liu_xi
_config:GetChild('pengpenghu').selected = data.special_peng_peng_hu
if _config:GetChild("xipai") then
_config:GetChild("xipai").selected = data.xi_pai
end
if oldGameVersion == 2 then
self.xipaiValueText.text = data.xi_pai_score / 100
self.xipaiValue = data.xi_pai_score / 100
self.anchouValueText.text = data.an_chou_score / 100
self.anchouValue = data.an_chou_score / 100
end
end
function M:OnChangeOption(ctype)
IGameInfo.OnChangeOption(self, ctype)
local play_list = self._config:GetController('play_list')
play_list.onChanged:Add(
function()
self._maxPlayer = play_list.selectedIndex + 2
self:ShowVariablePrice(ctype)
end
)
end
return M