|
-
- local CreateRoom_xichong = class("CreateRoom_xichong", require("luaScript.Views.CreateRoom.CreateRoomItemBase"))
-
- --[[
- isCreateRoom和defaultValus决定了从哪里读取默认值
- isCreateRoom 为true时,从本地文件读取,defaultValus无效.
- 否则使用defaultValus的值
- defaultValus : 跟服务器strGameInfo对应的json对象
- --]]
- function CreateRoom_xichong:ctor(defaultValues)
- CreateRoom_xichong.super.ctor(self, defaultValues, "CreateRoom_xichong.json");
-
- local ui = loadUI("res/ui/ui_chuangjian/zp_chuangjian_xichongkaokao.ui");
- self.ui = ui;
- self:addChild(ui);
-
- self.JuShuRadioManager = import("luaScript.Tools.RadioManager"):new();
- self.PayRadioManager = import("luaScript.Tools.RadioManager"):new();
- self.PiaoRadioManager = import("luaScript.Tools.RadioManager"):new();
- self.FanshuManager = import("luaScript.Tools.RadioManager"):new();
- -- 人数 - 单选
- self.pcountRadioManager = import("luaScript.Tools.RadioManager"):new()
- -- 发牌方数
- self.WanfaManager = import("luaScript.Tools.CheckBoxManager"):new()
- -- 其他选项
- self.otherCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new()
-
- self:onHideCestView() -- 隐藏cest的界面
- end
-
-
- function CreateRoom_xichong: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_xichong: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_xichong: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_xichong:onEnter()
- CreateRoom_xichong.super.onEnter(self)
-
- -- 整理不同局数对应的房卡消耗
- local ttCost = {}
- local gameConfig = app.user:getGameConfig(GAME_IDS.xichongkk);
- 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 1
- self.PiaoRadioManager: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.WanfaManager then
- self.WanfaManager:addItem(self.ui.Items.CheckBox_8, "shibalan",0x0001, 0); -- 十八烂
- self.WanfaManager:addItem(self.ui.Items.CheckBox_9, "kewanjiao", 0x0002, 0); -- 可弯叫
- self.WanfaManager:addItem(self.ui.Items.CheckBox_13, "zhanshanwanfa", 0x0004, 0); -- 可弯叫
-
- -- 设置默认状态
- local defaultValue = self:getDefaultValue("specialRule") or 1
-
- local selecteds = {}
- if getNumBand(defaultValue, 0x0001)>0 then
- table.insert(selecteds, "shibalan")
- end
- if getNumBand(defaultValue, 0x0002)>0 then
- table.insert(selecteds, "kewanjiao")
- end
-
- if getNumBand(defaultValue, 0x0004)>0 then
- table.insert(selecteds, "zhanshanwanfa")
- end
-
- self.WanfaManager:setDefault(selecteds);
- end
-
- self.ui.Items.CheckBox_11:setVisible(false)
- self.ui.Items.CheckBox_12:setVisible(false)
- -- 玩法 specialRule
- if self.FanshuManager then
- self.FanshuManager:addItem(self.ui.Items.CheckBox_10, 3); -- 限3番
- --self.FanshuManager:addItem(self.ui.Items.CheckBox_11, 4); -- 限4番
- --self.FanshuManager:addItem(self.ui.Items.CheckBox_12, 0); -- 不封顶
-
- -- 设置默认数据
- local defaultValue = self:getDefaultValue("highLimit") or 3
- self.FanshuManager:setDefault(tonumber(defaultValue));
- 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 -1
- local startMode = self:getDefaultValue("startMode") or 0
- if startMode == 1 then
- defaultValue = -1
- end
- self.pcountRadioManager:setDefault(defaultValue)
- end
-
- self:initOtherCheckBoxManager()
- self:initLayoutEvent()
- self:initJiFenBeiShu()
-
- end
- ---
- -- 初始化其他选项
- -- @return
- --
- function CreateRoom_xichong: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_xichong: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_xichong: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_xichong: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_xichong: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_xichong: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_xichong:getRuleResult()
- local game_num = self.JuShuRadioManager:getResult()
- local payMode = self.PayRadioManager:getResult()
- local highLimit = self.FanshuManager:getResult();
- local wanFaResult = self.WanfaManager:getResult2();
- local playnum = self.pcountRadioManager:getResult()--玩家人数
- local Piaorule = self.PiaoRadioManager:getResult()
- local startMode = 0
- if playnum == -1 then--选择的是快速组局
- --playnum = 4
- startMode = 1
- end
-
- local specialrule = 0
-
- for k, v in pairs(wanFaResult) do
- if v > 0 then
- specialrule = getNumOr(specialrule, v);
- end
- end
-
- local other = self.otherCheckBoxManager:getResult2()
- local forbidProp = other["forbidProp"]
- local forbidVoice = other["forbidVoice"]
- self.defaultValus =
- {
- gamerule = 1;
- --jushu = jushu;
- game_num = game_num,
- --biHu = 1;
- deductRule = payMode,
- areaNo = app.user.areano,
- startMode = startMode,
- playnum = playnum,
- specialRule = specialrule,
- 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_xichong
|