changhong/lua_probject/extend_project/extend/majiang/changsha/EXGameInfo.lua

350 lines
11 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/majiang/changsha/ui/Info_MJ_ChangSha")
return self
end
function M:FillData()
self._maxPlayer = 4 -- 默认玩家人数
self._roundChoice = 4 -- 回合选项数
if oldGameVersion==1 then
self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_ChangSha/Cgm_create_room")
else
self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_ChangSha/Cgm_create_room_yueyang")
end
if oldGameVersion==2 then
self._config:GetController("xipai").selectedIndex=0
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/1000
self.xipaiValue=value/1000
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/1000
self.anchouValue=value/1000
end, 3, nil)
gniv:Show()
end
)
end
end
local _help_url= "ui://Info_MJ_ChangSha/Com_help"
function M:GetHelpUrl()
return _help_url
end
local _icon_url = "ui://Info_MJ_ChangSha/icon"
function M:GetIconUrl()
return _icon_url
end
local _icon_url1 = "ui://Info_MJ_ChangSha/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 + 1 --== 0 and 1 or 2
self._maxPlayer = _config:GetController("play_list").selectedIndex+2
local zhuangxian = _config:GetChild("btn_zhuangxian").selected and true or false
-- local piaofen = _config:GetChild("btn_piaofen").selected and true or false
local zimo = _config:GetChild("btn_zimo").selected and true or false
local AA = _config:GetController("Cost").selectedIndex
-- local liuliushun = _config:GetChild("btn_liuliushun").selected and true or false
-- local queyise = _config:GetChild("btn_queyise").selected and true or false
-- local banbanhu = _config:GetChild("btn_banbanhu").selected and true or false
-- local dasixi = _config:GetChild("btn_dasixi").selected and true or false
local jiejiegao = _config:GetChild("btn_jiejiegao").selected and true or false
local santong = _config:GetChild("btn_santong").selected and true or false
local yizhihua = _config:GetChild("btn_yizhihua").selected and true or false
local zhongtusixi = _config:GetChild("btn_zhongtusixi").selected and true or false
local zhongtuliuliushun = _config:GetChild("btn_zhongtuliuliushun").selected and true or false
local niao_type = _config:GetController("niao").selectedIndex
local niao_num = _config:GetController("niao_num").selectedIndex
local niao_db_num = _config:GetController("niao_db_num").selectedIndex
local niao = niao_type == 1 and (niao_db_num == 0 and 1 or 2) or (niao_type == 0 and (niao_num == 0 and 2 or (niao_num == 1 and 4 or 6)) or 2)
local piao_niao = _config:GetChild("btn_piao_niao").selected
local two_pair = _config:GetChild("btn_two_pair").selected
local no_jiang = _config:GetChild("btn_no_jiang").selected
local four_win = _config:GetChild("btn_four_win").selected
local native_hu = _config:GetChild("btn_native_hu").selected
local queyimen = _config:GetChild("btn_queyimen").selected
local fengding = _config:GetChild("btn_fengding").selected
local banyiquan = _config:GetChild("btn_banyiquan").selected
local menqing = _config:GetChild("btn_menqing").selected
local fengding_score=0
if _config:GetController("fengding") then
fengding_score=_config:GetController("fengding").selectedIndex
end
local piao_niao1=0
if _config:GetController('piao') then
piao_niao1=_config:GetController('piao').selectedIndex
end
local piao1=false
local piao2=false
local piao3=false
local piao_niao_opt=0
if piao_niao1==2 then
piao_niao_opt=_config:GetController("piaofen").selectedIndex
end
local xi_pai=false
local xi_paifen=0
if _config:GetChild("xipai") then
xi_pai=_config:GetChild("xipai").selected
end
local niaofen_opt=0
local niaofen_score=1
local difen_score=1
local kai_gong=0
if oldGameVersion==2 then
niaofen_opt=_config:GetController("niaoadd").selectedIndex
niaofen_score= tonumber(_config:GetController("niaodf").selectedPage)
difen_score= tonumber(_config:GetController("jcdifen").selectedPage)
kai_gong=_config:GetController("kaigang").selectedIndex
end
---------
local _data = {}
_data["opt"] = round
_data["maxPlayers"] = self._maxPlayer
_data["zhuangxian"] = zhuangxian
_data["zimo"] = zimo
_data["AA"] = AA
-- _data["piaofen"] = piaofen
-- _data["liuliushun"] = liuliushun
-- _data["queyise"] = queyise
-- _data["banbanhu"] = banbanhu
-- _data["dasixi"] = dasixi
_data["jiejiegao"] = jiejiegao
_data["santong"] = santong
_data["yizhihua"] = yizhihua
_data["zhongtusixi"] = zhongtusixi
_data["zhongtuliuliushun"] = zhongtuliuliushun
_data["niao_type"] = niao_type
if oldGameVersion==1 then
_data["niao"] = niao
else
_data["niao"] = tonumber(_config:GetController("niao_num").selectedPage)
end
if oldGameVersion==1 then
_data["piao_niao"] = piao_niao
else
_data["piao_niao"] = piao_niao1
end
_data["two_pair"] = two_pair
_data["no_jiang"] = no_jiang
_data["four_win"] = four_win
_data["native_hu"] = native_hu
_data["queyimen"] = queyimen
_data["fengding"] = fengding
_data["banyiquan"] = banyiquan
_data["menqing"] = menqing
_data["fengding_score"] = fengding_score
--_data['piao'] = piao
_data['piao1'] = piao1
_data['piao2'] = piao2
_data['piao3'] = piao3
auto_piao=false
if piao_niao1==2 then
if piao1 or piao2 or piao3 then
auto_piao=true
end
end
if oldGameVersion==2 then
_data['auto_piao'] = auto_piao
end
_data['xi_pai'] = xi_pai
_data['piao_niao_opt'] = piao_niao_opt
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*1000
_data['an_chou_score'] = an_chou_score*1000
if oldGameVersion==2 then
_data['niaofen_opt'] = niaofen_opt
_data['niaofen_score'] = niaofen_score
_data['difen_score'] = difen_score
_data['kai_gong'] = kai_gong
end
pt(_data)
return _data
end
function M:LoadConfigData(data)
pt(data)
local _config = self._config
_config:GetController("round").selectedIndex = data.opt - 1 -- == 1 and 0 or 1
_config:GetController("play_list").selectedIndex = data.maxPlayers-2
_config:GetChild("btn_zhuangxian").selected = data.zhuangxian
_config:GetChild("btn_zimo").selected = data.zimo
_config:GetController("Cost").selectedIndex = data.AA
-- _config:GetChild("btn_piaofen").selected = data.piaofen
-- _config:GetChild("btn_liuliushun").selected = data.liuliushun
-- _config:GetChild("btn_queyise").selected = data.queyise
-- _config:GetChild("btn_banbanhu").selected = data.banbanhu
-- _config:GetChild("btn_dasixi").selected = data.dasixi
_config:GetChild("btn_jiejiegao").selected = data.jiejiegao
_config:GetChild("btn_santong").selected = data.santong
_config:GetChild("btn_yizhihua").selected = data.yizhihua
_config:GetChild("btn_zhongtusixi").selected = data.zhongtusixi
_config:GetChild("btn_zhongtuliuliushun").selected = data.zhongtuliuliushun
_config:GetController("niao").selectedIndex = data.niao_type
if oldGameVersion==1 then
_config:GetController("niao_num").selectedIndex = data.niao_type ~= 0 and 0 or (data.niao == 4 and 1 or (data.niao == 6 and 2 or 0))
else
_config:GetController("niao_num").selectedIndex=data.niao/2-1
end
_config:GetController("niao_db_num").selectedIndex = data.niao_type ~= 1 and 0 or (data.niao == 1 and 0 or 1)
if oldGameVersion==1 then
_config:GetChild("btn_piao_niao").selected = data.piao_niao
end
_config:GetChild("btn_two_pair").selected = data.two_pair
_config:GetChild("btn_no_jiang").selected = data.no_jiang
_config:GetChild("btn_four_win").selected = data.four_win
_config:GetChild("btn_native_hu").selected = data.native_hu
_config:GetChild("btn_queyimen").selected = data.queyimen
_config:GetChild("btn_fengding").selected = data.fengding or false
_config:GetChild("btn_banyiquan").selected = data.banyiquan or false
_config:GetChild("btn_menqing").selected = data.menqing or false
if _config:GetController("fengding") then
_config:GetController("fengding").selectedIndex=data.fengding_score
end
if _config:GetController("piao") then
_config:GetController("piao").selectedIndex=data.piao_niao
_config:GetChild('pf1').selected=data.piao1
_config:GetChild('pf2').selected=data.piao2
_config:GetChild('pf3').selected=data.piao3
end
if _config:GetChild("xipai") then
_config:GetChild("xipai").selected=data.xi_pai
end
if _config:GetController("piaofen") then
_config:GetController("piaofen").selectedIndex=data.piao_niao_opt
end
if oldGameVersion==2 then
self.xipaiValueText.text=data.xi_pai_score/1000
self.xipaiValue=data.xi_pai_score/1000
self.anchouValueText.text=data.an_chou_score/1000
self.anchouValue=data.an_chou_score/1000
end
if oldGameVersion==2 then
_config:GetController("niaoadd").selectedIndex=data.niaofen_opt or 0
_config:GetController("niaodf").selectedIndex=data.niaofen_score-1
_config:GetController("jcdifen").selectedIndex=data.difen_score-1
_config:GetController("kaigang").selectedIndex=data.kai_gong
end
end
return M