|
-
- local CreateRoom_nanchong = class("CreateRoom_nanchong", require("luaScript.Views.CreateRoom.CreateRoomItemBase"))
-
- --[[
- isCreateRoom和defaultValus决定了从哪里读取默认值
- isCreateRoom 为true时,从本地文件读取,defaultValus无效.
- 否则使用defaultValus的值
- defaultValus : 跟服务器strGameInfo对应的json对象
- --]]
- function CreateRoom_nanchong:ctor(defaultValues)
- CreateRoom_nanchong.super.ctor(self, defaultValues, "CreateRoom_nanchong.json");
-
- local ui = loadUI("res/ui/ui_chuangjian/zp_chuangjian_nanchongkaokao.ui");
- self.ui = ui;
- self:addChild(ui);
-
- logD("CreateRoom_nanchong:ctor self.ui.Items:", table.tostring(self.ui.Items))
-
- -- 局数
- self.JuShuRadioManager = import("luaScript.Tools.RadioManager"):new();
- -- 房卡
- self.PayRadioManager = import("luaScript.Tools.RadioManager"):new()
- -- 人数
- self.pcountRadioManager = import("luaScript.Tools.RadioManager"):new()
- -- 飘
- self.PiaoRadioManager = import("luaScript.Tools.RadioManager"):new()
- -- 番数
- self.FanshuManager = import("luaScript.Tools.RadioManager"):new()
- -- 锥
- self.Zhui1RadioManager = import("luaScript.Tools.RadioManager"):new()
- -- 打法 (乱吃乱打 正吃正打)
- self.DafaRadioManager = import("luaScript.Tools.RadioManager"):new()
- -- 头当
- self.TouDangCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new()
- -- 推当
- self.TiuDangCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new()
- -- 滚翻或梯番
- self.BeishuRadioManager = import("luaScript.Tools.RadioManager"):new()
- --玩法
- self.WanfaCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new()
- -- 其他选项
- self.otherCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new()
-
- self:onHideCestView() -- 隐藏cest的界面
- end
-
-
- function CreateRoom_nanchong:onHideCestView()
- if self.ui.Items.Button_pay0_tips then
- self.ui.Items.Button_pay0_tips:setVisible(false)
- end
- if self.ui.Items.Button_pay1_tips then
- self.ui.Items.Button_pay1_tips:setVisible(false)
- end
- if self.ui.Items.ImageView_pay0_tips then
- self.ui.Items.ImageView_pay0_tips:setVisible(false)
- end
- if self.ui.Items.ImageView_pay1_tips then
- self.ui.Items.ImageView_pay1_tips:setVisible(false)
- end
- end
-
-
- function CreateRoom_nanchong:onShowCestView()
- if self.ui.Items.Text_pay0 then
- self.ui.Items.Text_pay0:setText("免费")
- end
- if self.ui.Items.Text_pay1 then
- self.ui.Items.Text_pay1:setText("自费")
- end
- if self.ui.Items.Button_pay0_tips then
- self.ui.Items.Button_pay0_tips:setVisible(true)
- end
- if self.ui.Items.Button_pay1_tips then
- self.ui.Items.Button_pay1_tips:setVisible(true)
- end
- if self.ui.Items.ImageView_pay0_tips then
- self.ui.Items.ImageView_pay0_tips:setVisible(false)
- end
- if self.ui.Items.Button_pay0_tips then
- self.ui.Items.Button_pay0_tips:registerClick(function()
- if self.ui.Items.ImageView_pay0_tips then
- local isVisible = not self.ui.Items.ImageView_pay0_tips:isVisible()
- self.ui.Items.ImageView_pay0_tips:setVisible(isVisible)
- end
- end)
- end
- if self.ui.Items.ImageView_pay1_tips then
- self.ui.Items.ImageView_pay1_tips:setVisible(false)
- end
- if self.ui.Items.Button_pay1_tips then
- self.ui.Items.Button_pay1_tips:registerClick(function()
- if self.ui.Items.ImageView_pay1_tips then
- local isVisible = not self.ui.Items.ImageView_pay1_tips:isVisible()
- self.ui.Items.ImageView_pay1_tips:setVisible(isVisible)
- end
- end)
- end
- end
-
- --根据局数获取房费
- function CreateRoom_nanchong:getCreateRoomCost(jushu)
- if self.cost then
- local costInfo = self.cost[jushu]
- if costInfo then
- local payMode = self.PayRadioManager:getResult()
- if payMode == 0 then
- return costInfo.requireCards or 0
- elseif payMode == 1 then
- return costInfo.requireCardsAA or 0
- end
- end
- end
- return 0
- end
-
- function CreateRoom_nanchong:onEnter()
- CreateRoom_nanchong.super.onEnter(self)
-
- -- 整理不同局数对应的房卡消耗
- local ttCost = {}
- local gameConfig = app.user:getGameConfig(GAME_IDS.nanchongkk);
- if gameConfig then
- local arrGameRound = toNumberArray(",")(gameConfig.gameRound)
- local arrRequireCards = toNumberArray(",")(gameConfig.requireCards)
- local arrRequireCardsAA = toNumberArray(",")(gameConfig.AArequireCards)
-
- for idx, gameRound in ipairs(arrGameRound) do
- ttCost[gameRound] =
- {
- requireCards = arrRequireCards[idx],
- requireCardsAA = arrRequireCardsAA[idx],
- }
- end
- end
- self.cost = ttCost
-
- -- 玩家选择局数后,更新房卡消耗
- local function updateCost(gameRound)
- local costInfo = ttCost[gameRound]
- if costInfo then
- self.ui.Items.Text_FangZhu:setText(tostring(costInfo.requireCards or 0))
- self.ui.Items.Text_AAPay:setText(tostring(costInfo.requireCardsAA or 0))
- end
- end
-
- -- 房费 deductRule
- if self.PayRadioManager then
- self.PayRadioManager:addItem(self.ui.Items.CheckBox_4, 1); -- AA支付
- self.PayRadioManager:addItem(self.ui.Items.CheckBox_5, 0); -- 房主支付
-
- -- 设置默认数据
- local defaultValue = self:getDefaultValue("deductRule") or 0
- self.PayRadioManager:setDefault(tonumber(defaultValue));
- --通知创建界面更新显示
- local function dispatchUpdateCost()
- app:dispatchEvent({name = "onChangePayMode"})
- end
- self.PayRadioManager:setCallback(dispatchUpdateCost);
- end
-
- -- 漂
- if self.PiaoRadioManager then
- self.PiaoRadioManager:addItem(self.ui.Items.CheckBox_6, 1); -- 随漂
- self.PiaoRadioManager:addItem(self.ui.Items.CheckBox_7, 0); -- 不飘
- self.PiaoRadioManager:addItem(self.ui.Items.CheckBox_16, 2);-- 定飘
-
- -- 设置默认数据
- local defaultValue = self:getDefaultValue("Piaorule") or 0
- self.PiaoRadioManager:setDefault(tonumber(defaultValue));
- end
-
- -- 番数
- if self.FanshuManager then
- self.FanshuManager:addItem(self.ui.Items.CheckBox_10, 1); -- 3番
- self.FanshuManager:addItem(self.ui.Items.CheckBox_11, 0); -- 4番
- self.FanshuManager:addItem(self.ui.Items.CheckBox_12, 2); -- 5番
-
- -- 设置默认数据
- local defaultValue = self:getDefaultValue("highLimit") or 1
- self.FanshuManager:setDefault(tonumber(defaultValue));
- end
-
- --快速成局说明
- self.ui.Items.ImageView_2:setVisible(false)
- self.ui.Items.Button_KSCJ:registerClick(function()
- playBtnEffect()
- self.ui.Items.ImageView_2:setVisible(not self.ui.Items.ImageView_2:isVisible())
- end)
-
- -- 特殊玩法
- if self.Zhui1RadioManager then
- self.Zhui1RadioManager:addItem(self.ui.Items.CheckBox_13, 0x0080); -- 吊锥
- self.Zhui1RadioManager:addItem(self.ui.Items.CheckBox_18, 0x0100); -- 扯锥
-
- -- 设置默认数据
- local defaultValue = self:getDefaultValue("specRule") or 0x0080
- self.Zhui1RadioManager:setDefault(tonumber(defaultValue));
- end
-
- --打法
- if self.DafaRadioManager then
- self.DafaRadioManager:addItem(self.ui.Items.CheckBox_19, 0x0200); -- 乱吃乱打
- self.DafaRadioManager:addItem(self.ui.Items.CheckBox_20, 0x0040); -- 正吃正打
-
- -- 设置默认数据
- local defaultValue = self:getDefaultValue("specRule") or 0x0200
- self.DafaRadioManager:setDefault(tonumber(defaultValue));
- end
-
- -- 头当推当
- if self.TouDangCheckBoxManager then
- self.TouDangCheckBoxManager:addItem(self.ui.Items.CheckBox_14, "toudang", 0x0010, 0) -- 头当
-
-
- -- 设置默认状态
- local defaultValue = self:getDefaultValue("specRule") or 0
-
- local selecteds = {};
- if getNumBand(defaultValue, 0x0010)>0 then
- table.insert(selecteds, "toudang")
- end
-
- self.TouDangCheckBoxManager:setDefault(selecteds);
- local function callBack()
- local bSel1 = self.ui.Items.CheckBox_14:getSelectedState()
- if bSel1 then
- self.ui.Items.CheckBox_15:setSelectedState(false)
- self.ui.Items.Text_20:setTextColor(cc.c4b(21,99,97,255))
- end
- end
- self.TouDangCheckBoxManager:setCallback(callBack);
- end
-
- if self.TiuDangCheckBoxManager then
- self.TiuDangCheckBoxManager:addItem(self.ui.Items.CheckBox_15, "tuidang", 0x0400, 0) -- 推当
- -- 设置默认状态
- local defaultValue = self:getDefaultValue("specRule") or 0x0400
-
- local selecteds = {};
- if getNumBand(defaultValue, 0x0400)>0 then
- table.insert(selecteds, "tuidang")
- end
- self.TiuDangCheckBoxManager:setDefault(selecteds);
-
- local function callBack()
- local bSel2 = self.ui.Items.CheckBox_15:getSelectedState()
- if bSel2 then
- self.ui.Items.CheckBox_14:setSelectedState(false)
- self.ui.Items.Text_19:setTextColor(cc.c4b(21,99,97,255))
- end
- end
- self.TiuDangCheckBoxManager:setCallback(callBack);
- end
-
-
- -- 滚翻梯番
- if self.BeishuRadioManager then
- self.BeishuRadioManager:addItem(self.ui.Items.CheckBox_31, 0x0800); -- 滚番
- self.BeishuRadioManager:addItem(self.ui.Items.CheckBox_32, 0x1000); -- 梯番
- -- 设置默认数据
- local defaultValue = self:getDefaultValue("specRule") or 0x0800
- self.BeishuRadioManager:setDefault(tonumber(defaultValue));
- end
-
- -- 玩法
- if self.WanfaCheckBoxManager then
- self.WanfaCheckBoxManager:addItem(self.ui.Items.CheckBox_17, "zhaochiwujiao", 0x0008, 0) -- 召吃无叫
- self.WanfaCheckBoxManager:addItem(self.ui.Items.CheckBox_23, "kewanjiao", 0x0002, 0) -- 可弯叫
- self.WanfaCheckBoxManager:addItem(self.ui.Items.CheckBox_24, "ruansigenjiafan", 0x2000, 0) -- 软四根加番
- self.WanfaCheckBoxManager:addItem(self.ui.Items.CheckBox_25, "xiaojiazimojiafan", 0x0020, 0) -- 小家自摸加番
- self.WanfaCheckBoxManager:addItem(self.ui.Items.CheckBox_26, "zhanshanwanfa", 0x0004, 0) -- 占山玩法
-
- -- 设置默认状态
- local defaultValue = self:getDefaultValue("specRule") or 0x0002
-
- local selecteds = {};
- if getNumBand(defaultValue, 0x0008)>0 then
- table.insert(selecteds, "zhaochiwujiao")
- end
- if getNumBand(defaultValue, 0x0002)>0 then
- table.insert(selecteds, "kewanjiao")
- end
- if getNumBand(defaultValue, 0x2000)>0 then
- table.insert(selecteds, "ruansigenjiafan")
- end
- if getNumBand(defaultValue, 0x0020)>0 then
- table.insert(selecteds, "xiaojiazimojiafan")
- end
- if getNumBand(defaultValue, 0x0004)>0 then
- table.insert(selecteds, "zhanshanwanfa")
- end
- self.WanfaCheckBoxManager:setDefault(selecteds);
- end
-
-
- -- 人数
- self.hadHideFangShu = false
- if self.pcountRadioManager then
- self.pcountRadioManager:addItem(self.ui.Items.CheckBox_playerCount_2, 3) -- (3人)
- self.pcountRadioManager:addItem(self.ui.Items.CheckBox_playerCount_3, 4) -- (4人)
- self.pcountRadioManager:addItem(self.ui.Items.CheckBox_playerCount_4, -1) -- (快速成局)
- local defaultValue = self:getDefaultValue("playnum") or 3
- local startMode = self:getDefaultValue("startMode") or 0
- if startMode == 3 then
- defaultValue = -1
- end
- self.pcountRadioManager:setDefault(defaultValue)
- self.ui.Items.CheckBox_25:setVisible(defaultValue == 4)
- -- 不需要重置勾选 JoonHyun 2021/4/13
- --self.ui.Items.CheckBox_25:setSelectedState(false)
- self.ui.Items.Text_37:setTextColor(cc.c4b(21,99,97,255))
- local function callback1(id)
- --local bSel = self.ui.Items.CheckBox_playerCount_3:getResult();
- --local result = self.pcountRadioManager:getResult()
- if id == 4 then
- self.ui.Items.CheckBox_25:setVisible(true)
- else
- self.ui.Items.CheckBox_25:setVisible(false)
- self.ui.Items.CheckBox_25:setSelectedState(false)
- self.ui.Items.Text_37:setTextColor(cc.c4b(21,99,97,255))
- end
- end
- self.pcountRadioManager:setCallback(callback1);
- end
-
- self:initOtherCheckBoxManager()
- self:initLayoutEvent()
- self:initJiFenBeiShu()
-
- end
- ---
- -- 初始化其他选项
- -- @return
- --
- function CreateRoom_nanchong:initOtherCheckBoxManager ()
- if not self.otherCheckBoxManager then
- return
- end
-
- self.otherCheckBoxManager:addItem(self.ui.Items.CheckBox_ForbidProp, "forbidProp", 1, 0)
- self.otherCheckBoxManager:addItem(self.ui.Items.CheckBox_ForbidChat, "forbidVoice", 1, 0)
- local forbidProp = self:getDefaultValue("forbidProp") or 0
- local forbidVoice = self:getDefaultValue("forbidVoice") or 0
- local defaults = {}
- if forbidProp > 0 then
- table.insert(defaults, "forbidProp")
- end
- if forbidVoice == 1 then
- table.insert(defaults, "forbidVoice")
- end
- end
- -- 面板的点击事件,点击面板后,隐藏所有提示
- function CreateRoom_nanchong:initLayoutEvent()
- self.ui.Items.Layout_3:registerClick(function()
- local buttons = {
- {buttonName = "Button_JFBS", tipsName = "ImageView_2"},
- {buttonName = "Button_JFBS", tipsName = "ImageView_JFBS"},
- };
-
- -- 隐藏其他提示信息
- for k, v in ipairs(buttons) do
- local tipsNode = self.ui.Items[v.tipsName]
- tipsNode:setVisible(false)
- end
- end)
- end
- -- 初始化积分倍数
- function CreateRoom_nanchong:initJiFenBeiShu()
- self.ui.Items.Button_jia:registerClick(handler(self, self.onClickAdd))
- self.ui.Items.Button_jian:registerClick(handler(self, self.onClickJian))
- --当前积分数值
- self.curJFBS = self:getDefaultValue("baseMulti") or 1;
- self:updateJiFenBeiShu()
- --积分倍数说明
- self.ui.Items.ImageView_JFBS:setVisible(false)
- self.ui.Items.Button_JFBS:registerClick(function()
- self.ui.Items.ImageView_JFBS:setVisible(not self.ui.Items.ImageView_JFBS:isVisible())
- end)
- end
- --更新积分倍数
- function CreateRoom_nanchong:updateJiFenBeiShu()
- self.ui.Items.Text_jifen:setText(self.curJFBS)
-
- self.ui.Items.Button_jia:setEnabled(self.curJFBS ~= 100)
- self.ui.Items.Button_jian:setEnabled(self.curJFBS ~= 1)
- end
- --按钮加
- function CreateRoom_nanchong:onClickAdd()
- playBtnEffect()
- if not self.curJFBS then
- return
- end
- self.curJFBS = self.curJFBS + 1
- if self.curJFBS >= 100 then
- self.curJFBS = 100;
- end
- self:updateJiFenBeiShu()
- end
- --按钮减
- function CreateRoom_nanchong:onClickJian()
- playBtnEffect()
- if not self.curJFBS then
- return
- end
- self.curJFBS = self.curJFBS - 1
- if self.curJFBS <= 0 then
- self.curJFBS = 1
- end
- self:updateJiFenBeiShu()
- end
-
- function CreateRoom_nanchong:getRuleResult()
- local game_num = self.JuShuRadioManager:getResult()
- local payMode = self.PayRadioManager:getResult()
- local highLimit = self.FanshuManager:getResult()
-
- local zhui = self.Zhui1RadioManager:getResult()
- local dafa = self.DafaRadioManager:getResult()
- local toudang = self.TouDangCheckBoxManager:getResult2()
- local tuidang = self.TiuDangCheckBoxManager:getResult2()
- local beishu = self.BeishuRadioManager:getResult()
- local wanFaResult = self.WanfaCheckBoxManager:getResult2()
-
- local playnum = self.pcountRadioManager:getResult()--玩家人数
- local Piaorule = self.PiaoRadioManager:getResult()
- local startMode = 0
- if playnum == -1 then--选择的是快速组局
- --playnum = 4
- startMode = 1
- end
-
- local specRule = 0
-
- for k, v in pairs(wanFaResult) do
- if v > 0 then
- specRule = getNumOr(specRule, v);
- end
- end
-
-
- specRule = getNumOr(specRule, zhui);
- specRule = getNumOr(specRule, dafa);
-
-
- for k, v in pairs(toudang) do
- if v > 0 then
- specRule = getNumOr(specRule, v);
- end
- end
-
- for k, v in pairs(tuidang) do
- if v > 0 then
- specRule = getNumOr(specRule, v);
- end
- end
-
- specRule = getNumOr(specRule, beishu);
-
-
- local other = self.otherCheckBoxManager:getResult2()
- local forbidProp = other["forbidProp"]
- local forbidVoice = other["forbidVoice"]
- self.defaultValus =
- {
- gamerule = 0;
- jushu = jushu;
- game_num = game_num,
- --biHu = 1;
- deductRule = payMode,
- areaNo = app.user.areano,
- startMode = startMode,
- playnum = playnum,
- specRule = specRule,
- highLimit = highLimit,
- Piaorule = Piaorule,
- baseMulti = self.curJFBS,
- forbidProp = forbidProp,
- forbidVoice = forbidVoice,
- }
-
- -- 保存玩家的选择
- self:saveDefaultValues()
-
- local strGameInfo = json.encode(self.defaultValus)
- return game_num, strGameInfo
- end
-
- return CreateRoom_nanchong
|