|
- -- local MJSelectRadioCompnent = require("luaScript.Views.CreateRoom.Compnent.MJSelectRadioCompnent")
- -- local MJGroupCompnent = require("luaScript.Views.CreateRoom.Compnent.MJGroupCompnent")
- -- local MJCheckBoxCompnent = require("luaScript.Views.CreateRoom.Compnent.MJCheckBoxCompnent")
- -- local MJWanFa=MJFramework.ImportWanFa("MaJiang.MJWanFa")
- local CreateRoomItemBase=require("luaScript.Views.CreateRoom.CreateRoomItemBase")
-
- local MJCreateRoomItem=class("huamajiangCreateRoomItem", CreateRoomItemBase)
-
- local SELECT_COLOR = cc.c4b(213,46,11,255)
- local NON_SELECT_COLOR = cc.c4b(21,99,97,255)
-
- function MJCreateRoomItem:ctor(defaultValues)
- MJCreateRoomItem.super.ctor(self, defaultValues, "huamajiang_room.json")
- local ui = loadUI("res/ui/ui_chuangjian/mj_createroom_huamajiang_three.ui");
- self.ui = ui;
- self:addChild(ui);
-
- self.JuShuRadioManager = import("luaScript.Tools.RadioManager"):new();
- --房费
- self.PayRadioManager = import("luaScript.Tools.RadioManager"):new();
- --人数
- self.PlayerNumRadioManager = import("luaScript.Tools.RadioManager"):new();
- -- 点杠花
- self.DianGangHuaRadioManager = import("luaScript.Tools.RadioManager"):new();
- -- 多头
- self.DuoTouRadioManager = import("luaScript.Tools.RadioManager"):new();
- --玩法
- self.WanFaCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new();
- --换三张
- self.HuanSanZhangRadioManager = import("luaScript.Tools.RadioManager"):new();
- --萝卜
- self.LuoBoRadioManager = import("luaScript.Tools.RadioManager"):new();
- --天胡全胡
- self.TianHuQuanHuCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new();
- --四人胡完
- self.SiRenHuWanCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new();
- --七对全胡
- self.QiDuiRadioManager = import("luaScript.Tools.RadioManager"):new();
- --神龙
- self.ShenLongRadioManager = import("luaScript.Tools.RadioManager"):new();
- -- 飘
- self.PiaoRadioManager = import("luaScript.Tools.RadioManager"):new();
- --封顶
- self.FengDingRadioManager = import("luaScript.Tools.RadioManager"):new();
- -- 其他选项
- self.otherCheckBoxManager = import("luaScript.Tools.CheckBoxManager"):new()
-
- self:onHideCestView() -- 隐藏cest的界面
- end
-
-
- function MJCreateRoomItem: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 MJCreateRoomItem: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 MJCreateRoomItem:onEnter()
- MJCreateRoomItem.super.onEnter(self)
- self:initPlayTips();
- self:initPayRadioManager();
- self:initPlayerNumRadioManager();
- self:initDianGangHuaRadioManager();
- self:initDuoTouRadioManager();
- self:initWanFaCheckBoxManager();
- self:initHuanSanZhangRadioManager();
- self:initLuoBoRadioManager();
- self:initTianHuQuanHuCheckBoxManager();
- self:initSiRenHuWanCheckBoxManager();
- self:initQiDuiRadioManager();
- self:initShenLongRadioManager();
- self:initPiaoRadioManager();
- self:initFengDingRadioManager();
- self:initOtherCheckBoxManager();
- self:initLayoutEvent()
- self:initJiFenBeiShu()
- end
- --[[/**
- * 父类调用
- * 根据局数获取房费
- * @param jushu
- * @return
- */--]]
- function MJCreateRoomItem:getCreateRoomCost(jushu)
- local payTypes = self:getPayTypes();
- if not payTypes then
- return 0;
- end
-
- local payInfo = payTypes[jushu]
- if not payInfo then
- return 0;
- end
-
- local payMode = self.PayRadioManager:getResult()
- if payMode == 0 then
- return payInfo.roomCard or 0
- elseif payMode == 1 then
- return payInfo.roomCardAA or 0
- end
- end
- ---
- --[[/**
- * 整理不同局数对应的房卡消耗
- * @param
- * @return
- */--]]
- function MJCreateRoomItem:getPayTypes( )
- local payTypes={}
- local gameConfig = app.user:getGameConfig(GAME_IDS.huamajiang)--app.gameId);
- if not gameConfig then
- return ;
- end
- local arrGameRound = toNumberArray(",")(gameConfig.gameRound)
- local arrRequireCards = toNumberArray(",")(gameConfig.requireCards)
- local arrRequireCardsAA = toNumberArray(",")(gameConfig.AArequireCards)
-
- for idx, gameRound in ipairs(arrGameRound) do
- payTypes[gameRound] =
- {
- roomCard = arrRequireCards[idx],
- roomCardAA = arrRequireCardsAA[idx],
- }
- end
- return payTypes;
- end
- --[[/**
- * 初始化帮助信息
- * @return
- */--]]
- function MJCreateRoomItem:initPlayTips()
- local buttons = {
- {buttonName = "Button_QuickStartTips", tipsName = "ImageView_QuickStartTips"},
- {buttonName = "Button_HuLuoBo", tipsName = "ImageView_HuLuoBo"},
- {buttonName = "Button_FeiPai", tipsName = "ImageView_FeiPai"},
- {buttonName = "Button_ChaoJiLuoBo", tipsName = "ImageView_ChaoJiLuoBo"},
- {buttonName = "Button_HuJiaMoPai", tipsName = "ImageView_HuJiaMoPai"},
- {buttonName = "Button_ZiDongHu", tipsName = "ImageView_ZiDongHu"},
- {buttonName = "Button_MoJiaHuPai", tipsName = "ImageView_MoJiaHuPai"},
- {buttonName = "Button_TianHuQuanHu", tipsName = "ImageView_TianHuQuanHu"},
- {buttonName = "Button_QiDui_1", tipsName = "ImageView_QiDui_1"},
- {buttonName = "Button_QiDui_2", tipsName = "ImageView_QiDui_2"},
- {buttonName = "Button_JFBS", tipsName = "ImageView_JFBS"},
- };
- -- 点击其中一个,隐藏其他提示信息
- local hideOtherTips = function (buttonName)
- for k, v in ipairs(buttons) do
- local btnNode = self.ui.Items[v.buttonName];
- local tipsNode = self.ui.Items[v.tipsName];
- if v.buttonName ~= buttonName then
- tipsNode:setVisible(false);
- end
- end
- end
- -- 注册问号按钮事件
- for k, v in ipairs(buttons) do
- local btnNode = self.ui.Items[v.buttonName];
- local tipsNode = self.ui.Items[v.tipsName];
-
- tipsNode:setVisible(false);
- btnNode:registerClick(handler(self, function (obj)
- local isVisible = tipsNode:isVisible();
- tipsNode:setVisible(not isVisible);
- hideOtherTips(v.buttonName);
- end));
- tipsNode:setTouchEnabled(true);
- end
-
- self.ui.Items["Button_ZiDongHu"]:setVisible(false); -- 隐藏胡家摸牌帮助
- end
- ---
- --[[/**
- * 初始化房费支付选项
- * @return
- */--]]
- function MJCreateRoomItem:initPayRadioManager ()
- if not self.PayRadioManager then
- return;
- end
-
- self.PayRadioManager:addItem(self.ui.Items.CheckBox_FangZhu, 0); -- 房主支付
- self.PayRadioManager:addItem(self.ui.Items.CheckBox_AAPay, 1); -- AA支付
- local default = self:getDefaultValue("deductRule") or 0
- self.PayRadioManager:setDefault(default)
-
- self.PayRadioManager:setCallback(function ()
- -- 通知创建界面更新显示
- app:dispatchEvent({name = "onChangePayMode"})
- end);
- self:setDefaultTextColor(self.PayRadioManager,"Text_pay")
- end
- --[[/**
- * 初始化人数选项
- * @return
- */--]]
- function MJCreateRoomItem:initPlayerNumRadioManager ()
- if not self.PlayerNumRadioManager then
- return ;
- end
-
- self.PlayerNumRadioManager:addItem(self.ui.Items.CheckBox_PlayerNum_0, 0);
- self.PlayerNumRadioManager:addItem(self.ui.Items.CheckBox_PlayerNum_2, 2);
- self.PlayerNumRadioManager:addItem(self.ui.Items.CheckBox_PlayerNum_3, 3);
- self.PlayerNumRadioManager:addItem(self.ui.Items.CheckBox_PlayerNum_4, 4);
-
- local defaultValue = self:getDefaultValue("playnum") or 3
- local isfaststart = self:getDefaultValue("isfaststart") or 1
-
- if isfaststart==1 then
- defaultValue = 0;
- end
- self.PlayerNumRadioManager:setDefault(defaultValue);
-
- local function refreshWanFaItems(value)
- if value == 2 then
- -- self.ui.Items.CheckBox_QuPai:setSelectedState(true);
- -- self.PiaoRadioManager:setDefault(0);
- -- self.ui.Items.CheckBox_HuJiaMoPai:setSelectedState(false);
- self.ui.Items.CheckBox_HuLuoBo:setSelectedState(true);
- self.ui.Items.CheckBox_ChaoJiLuoBo:setEnabled(true);
- self.ui.Items.CheckBox_MoJiaHuPai:setSelectedState(false);
- end
-
- -- self.ui.Items.CheckBox_HuJiaMoPai:setEnabled(value ~= 2);
- self.ui.Items.CheckBox_HuLuoBo:setEnabled(value ~= 2);
- -- self.ui.Items.CheckBox_QuPai:setEnabled(value ~= 2);
- -- self.ui.Items.CheckBox_Piao_0:setEnabled(value ~= 2);
- -- self.ui.Items.CheckBox_Piao_1:setEnabled(value ~= 2);
- -- self.ui.Items.CheckBox_Piao_2:setEnabled(value ~= 2);
- self.ui.Items.CheckBox_MoJiaHuPai:setEnabled(value ~= 2);
-
-
- --新增四人胡完
- self.ui.Items.CheckBox_SiRenHuWan:setVisible(value == 4 or value == 0)
-
- --天胡全胡
- self.ui.Items.CheckBox_TianHuQuanHu:setVisible(value ~= 2);
- --天胡全胡提示按钮
- self.ui.Items.Button_TianHuQuanHu:setVisible(value ~= 2);
-
- --神龙和七对全胡二人不显示
- self.ui.Items.Layout_Play_5:setVisible(value ~= 2);
- self.ui.Items.Layout_QiDui:setVisible(value ~= 2);
- end
-
- self.PlayerNumRadioManager:setCallback(function (value)
- refreshWanFaItems(value);
- self.ui.Items.Layout_1:requestDoLayout()
- self.ui.Items.Layout_1:doLayout()
- end);
-
- refreshWanFaItems(defaultValue);
- end
- --[[/**
- * 初始化点杠花选项
- * @param
- * @return
- */--]]
- function MJCreateRoomItem:initDianGangHuaRadioManager( )
- if not self.DianGangHuaRadioManager then
- return ;
- end
-
- self.DianGangHuaRadioManager:addItem(self.ui.Items.CheckBox_gang_1, 0x02); -- 自摸
- self.DianGangHuaRadioManager:addItem(self.ui.Items.CheckBox_gang_2, 0x01); -- 点炮
-
- local specRule = self:getDefaultValue("specRule") or 0;
- local defaultValue = 0x02;
- if getNumBand(specRule, 0x01) > 0 then
- defaultValue = 0x01;
- end
-
- if getNumBand(specRule, 0x02) > 0 then
- defaultValue = 0x02;
- end
-
- self.DianGangHuaRadioManager:setDefault(defaultValue);
- end
- --[[/**
- * 初始化多头选项
- * @return
- */--]]
- function MJCreateRoomItem:initDuoTouRadioManager ()
- if not self.DuoTouRadioManager then
- return ;
- end
-
- self.DuoTouRadioManager:addItem(self.ui.Items.CheckBox_DuoTou_1, 1); -- 多头杠加番
- self.DuoTouRadioManager:addItem(self.ui.Items.CheckBox_DuoTou_2, 2); -- 多头加番
-
- local defaultValue = self:getDefaultValue("duogang") or 2;
- self.DuoTouRadioManager:setDefault(defaultValue);
- end
-
- --[[/**
- * 初始化换三张选项
- * @return
- */--]]
- function MJCreateRoomItem:initHuanSanZhangRadioManager()
- if not self.HuanSanZhangRadioManager then
- return ;
- end
- self.HuanSanZhangRadioManager:addItem(self.ui.Items.CheckBox_HuanSanZhang, 0x1000)
- self.HuanSanZhangRadioManager:addItem(self.ui.Items.CheckBox_BuHuanZhang, 0x2000)
- self.HuanSanZhangRadioManager:addItem(self.ui.Items.CheckBox_HunSeHuanSanZhang, 0x80000)
-
- -- 设置默认数据
- local specRule = self:getDefaultValue("specRule") or 0x2000
- local defaultValue = 0x2000;
- if getNumBand(specRule, 0x1000) > 0 then
- defaultValue = 0x1000
- end
- if getNumBand(specRule, 0x2000) > 0 then
- defaultValue = 0x2000
- end
- if getNumBand(specRule, 0x80000) > 0 then
- defaultValue = 0x80000
- end
-
- self.HuanSanZhangRadioManager:setDefault(defaultValue);
- end
-
- --[[/**
- * 初始化起始萝卜选项
- * @return
- */--]]
- function MJCreateRoomItem:initLuoBoRadioManager()
- if not self.LuoBoRadioManager then
- return ;
- end
- self.LuoBoRadioManager:addItem(self.ui.Items.CheckBox_Luobo_2, 0x4000)
- self.LuoBoRadioManager:addItem(self.ui.Items.CheckBox_Luobo_4, 0x8000)
- self.LuoBoRadioManager:addItem(self.ui.Items.CheckBox_Luobo_6, 0x10000)
-
- local specRule = self:getDefaultValue("specRule") or 0;
- local defaultValue = 0x8000;
- if getNumBand(specRule, 0x4000) > 0 then
- defaultValue = 0x4000;
- end
-
- if getNumBand(specRule, 0x8000) > 0 then
- defaultValue = 0x8000;
- end
-
- if getNumBand(specRule, 0x10000) > 0 then
- defaultValue = 0x10000;
- end
- self.LuoBoRadioManager:setDefault(tonumber(defaultValue));
- end
-
- --[[/**
- * 初始化天胡全胡选项
- * @return
- */--]]
- function MJCreateRoomItem:initTianHuQuanHuCheckBoxManager()
- if not self.TianHuQuanHuCheckBoxManager then
- return ;
- end
-
- local checkbox = self.TianHuQuanHuCheckBoxManager;
- checkbox:addItem(self.ui.Items.CheckBox_TianHuQuanHu,"tianhuquanhu", 0x20000, 0)
-
- -- 设置默认状态
- local defaultValue = self:getDefaultValue("specRule") or 0x20000
- local selecteds = {};
- if getNumBand(defaultValue, 0x20000)>0 then
- table.insert(selecteds, "tianhuquanhu")
- end
- checkbox:setDefault(selecteds)
- end
-
- --[[/**
- * 初始化四人全胡选项
- * @return
- */--]]
- function MJCreateRoomItem:initSiRenHuWanCheckBoxManager()
- if not self.SiRenHuWanCheckBoxManager then
- return ;
- end
-
- local checkbox = self.SiRenHuWanCheckBoxManager;
- checkbox:addItem(self.ui.Items.CheckBox_SiRenHuWan,"sirenhuwan", 0x40000, 0)
-
-
- -- 设置默认状态
- local defaultValue = self:getDefaultValue("specRule") or 0x40000
- local selecteds = {};
- if getNumBand(defaultValue, 0x40000)>0 then
- table.insert(selecteds, "sirenhuwan")
- end
- checkbox:setDefault(selecteds)
- end
-
- --[[/**
- * 初始化七对选项
- * @return
- */--]]
- function MJCreateRoomItem:initQiDuiRadioManager()
- if not self.QiDuiRadioManager then
- return ;
- end
- self.QiDuiRadioManager:addItem(self.ui.Items.CheckBox_QiDui_0, 0)
- self.QiDuiRadioManager:addItem(self.ui.Items.CheckBox_QiDui_1, 1)
- self.QiDuiRadioManager:addItem(self.ui.Items.CheckBox_QiDui_2, 2)
-
- local defaultValue = self:getDefaultValue("QiDuiQuanHu") or 1;
- self.QiDuiRadioManager:setDefault(defaultValue);
- end
-
- --[[/**
- * 初始化神龙选项
- * @return
- */--]]
- function MJCreateRoomItem:initShenLongRadioManager()
- if not self.ShenLongRadioManager then
- return ;
- end
- self.ShenLongRadioManager:addItem(self.ui.Items.CheckBox_ShenLong_0, 0)
- self.ShenLongRadioManager:addItem(self.ui.Items.CheckBox_ShenLong_1, 10)
- self.ShenLongRadioManager:addItem(self.ui.Items.CheckBox_ShenLong_2, 20)
-
- local defaultValue = self:getDefaultValue("ShenLong") or 10;
- self.ShenLongRadioManager:setDefault(defaultValue);
- end
-
- --[[/**
- * 初始化玩法选项
- * @return
- */--]]
- function MJCreateRoomItem:initWanFaCheckBoxManager ()
- if not self.WanFaCheckBoxManager then
- return ;
- end
-
- local checkbox = self.WanFaCheckBoxManager;
- checkbox:addItem(self.ui.Items.CheckBox_HuJiaMoPai, "hujiamopai", 0x04, 0);--胡家默牌
- checkbox:addItem(self.ui.Items.CheckBox_ZiDongHu, "zidonghu", 0x08, 0);--自动胡
- checkbox:addItem(self.ui.Items.CheckBox_FeiPai, "feipai", 0x10, 0);--废牌
- checkbox:addItem(self.ui.Items.CheckBox_HuLuoBo, "huluobo", 0x20, 0);--胡萝卜
- checkbox:addItem(self.ui.Items.CheckBox_ChaoJiLuoBo, "chaojiluobo", 0x40, 0);--超级萝卜
- checkbox:addItem(self.ui.Items.CheckBox_MoJiaHuPai, "mojiahupai", 0x100, 0);--末家胡牌
- checkbox:addItem(self.ui.Items.CheckBox_HuJiaQiangGang, "hujiaqianggang", 0x200, 0);--胡家可抢杠
- checkbox:addItem(self.ui.Items.CheckBox_ZhuanShou, "zhuanshou", 0x400, 0); -- 转手
- checkbox:addItem(self.ui.Items.CheckBox_ChaJiao, "chajiao", 1, 0) -- 查叫
- checkbox:addItem(self.ui.Items.CheckBox_NoQiangGang, "noqianggang", 0x800, 0); -- 不可抢杠胡家
-
-
- local refreshItems = function ()
- if not tolua.isnull(self.WanFaCheckBoxManager) then
- local result = self.WanFaCheckBoxManager:getResult2();
- self.ui.Items.CheckBox_ChaoJiLuoBo:setEnabled(result["huluobo"] > 0);
- if result["huluobo"] <= 0 then
- self.WanFaCheckBoxManager:setSelectedState("chaojiluobo", false);
- end
- end
- end
-
- local specRule = self:getDefaultValue("specRule") or 0;
- local defaultValues = {};
-
- local chajiaoValue = self:getDefaultValue("chajiao") or 1;
-
- if chajiaoValue > 0 then
- table.insert( defaultValues, "chajiao")
- end
-
- if specRule ~= 0 then
- if getNumBand(specRule, 0x04) > 0 then
- table.insert(defaultValues, "hujiamopai");
- end
-
- if getNumBand(specRule, 0x08) > 0 then
- table.insert(defaultValues, "zidonghu");
- end
-
- if getNumBand(specRule, 0x10) > 0 then
- table.insert(defaultValues, "feipai");
- end
-
- if getNumBand(specRule, 0x20) > 0 then
- table.insert(defaultValues, "huluobo");
- end
-
- if getNumBand(specRule, 0x40) > 0 then
- table.insert(defaultValues, "chaojiluobo");
- end
-
- if getNumBand(specRule, 0x100) > 0 then
- table.insert(defaultValues, "mojiahupai");
- end
-
- if getNumBand(specRule, 0x200) > 0 then
- table.insert(defaultValues, "hujiaqianggang");
- end
-
- if getNumBand(specRule, 0x400) > 0 then
- table.insert(defaultValues, "zhuanshou")
- end
-
- if getNumBand(specRule, 0x800) > 0 then
- table.insert(defaultValues, "noqianggang")
- end
- else
- table.insert(defaultValues, "hujiamopai");
- table.insert(defaultValues, "zidonghu");
- table.insert(defaultValues, "huluobo");
- table.insert(defaultValues, "chaojiluobo");
- end
-
- checkbox:setDefault(defaultValues)
- checkbox:setCallback(refreshItems);
- refreshItems();
- end
- --[[/**
- * 初始化飘选项
- * @return
- */--]]
- function MJCreateRoomItem:initPiaoRadioManager ()
- if not self.PiaoRadioManager then
- return ;
- end
-
- self.PiaoRadioManager:addItem(self.ui.Items.CheckBox_Piao_0, 0); -- 不飘
- self.PiaoRadioManager:addItem(self.ui.Items.CheckBox_Piao_1, 1); -- 随飘
- self.PiaoRadioManager:addItem(self.ui.Items.CheckBox_Piao_2, 2); -- 必飘
-
- local defaultValue = self:getDefaultValue("piaomode") or 0;
- self.PiaoRadioManager:setDefault(defaultValue);
- end
- --[[/**
- * 初始化封顶选项
- * @return
- */--]]
- function MJCreateRoomItem:initFengDingRadioManager ()
- if not self.FengDingRadioManager then
- return ;
- end
-
- self.FengDingRadioManager:addItem(self.ui.Items.CheckBox_0fan, -1); -- 封顶3番
- self.FengDingRadioManager:addItem(self.ui.Items.CheckBox_3fan, 3); -- 封顶3番
- self.FengDingRadioManager:addItem(self.ui.Items.CheckBox_4fan, 4); -- 封顶4番
- self.FengDingRadioManager:addItem(self.ui.Items.CheckBox_5fan, 5); -- 封顶5番
-
- local defaultValue = self:getDefaultValue("limitfan") or 5;
- self.FengDingRadioManager:setDefault(defaultValue);
- end
-
- -- 面板的点击事件,点击面板后,隐藏所有提示
- function MJCreateRoomItem:initLayoutEvent()
- self.ui.Items.Layout_1:registerClick(function ()
- local buttons = {
- {buttonName = "Button_QuickStartTips", tipsName = "ImageView_QuickStartTips"},
- {buttonName = "Button_JFBS", tipsName = "ImageView_JFBS"},
- {buttonName = "Button_HuLuoBo", tipsName = "ImageView_HuLuoBo"},
- {buttonName = "Button_MoJiaHuPai", tipsName = "ImageView_MoJiaHuPai"},
- {buttonName = "Button_HuJiaMoPai", tipsName = "ImageView_HuJiaMoPai"},
- {buttonName = "Button_ZiDongHu", tipsName = "ImageView_ZiDongHu"},
- {buttonName = "Button_ChaoJiLuoBo", tipsName = "ImageView_ChaoJiLuoBo"},
- {buttonName = "Button_FeiPai", tipsName = "ImageView_FeiPai"},
- {buttonName = "Button_TianHuQuanHu", tipsName = "ImageView_TianHuQuanHu"},
- {buttonName = "Button_QiDui_1", tipsName = "ImageView_QiDui_1"},
- {buttonName = "Button_QiDui_2", tipsName = "ImageView_QiDui_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
- ---
- -- 初始化其他选项
- -- @return
- --
- function MJCreateRoomItem: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_ForbidVoice, "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
- self.otherCheckBoxManager:setDefault(defaults)
- end
- -- 初始化积分倍数
- function MJCreateRoomItem: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)
-
- -- self.ui.Items.Layout_JiFenBeiShu:setVisible(false)
- end
- --更新积分倍数
- function MJCreateRoomItem:updateJiFenBeiShu()
- self.curJFBS = self.curJFBS >= 1.0 and math.floor(self.curJFBS) or self.curJFBS;
- 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 ~= 0.1)
- end
- --按钮加
- function MJCreateRoomItem:onClickAdd()
- playBtnEffect()
- if not self.curJFBS then
- return
- end
- if self.curJFBS >= 1.0 then
- self.curJFBS = self.curJFBS + 1.0
- else
- self.curJFBS = self.curJFBS + 0.1
- end
- if self.curJFBS >= 100 then
- self.curJFBS = 100;
- end
- self:updateJiFenBeiShu()
- end
- --按钮减
- function MJCreateRoomItem:onClickJian()
- playBtnEffect()
- if not self.curJFBS then
- return
- end
- if self.curJFBS <= 1.0 then
- self.curJFBS = self.curJFBS - 0.1
- else
- self.curJFBS = self.curJFBS - 1.0
- end
- if self.curJFBS <= 0.1 then
- self.curJFBS = 0.1
- end
- self:updateJiFenBeiShu()
- end
-
- --设置选中值默认颜色
- function MJCreateRoomItem:setDefaultTextColor(radio,text)
- if radio then
- local index = radio:getResult()
- local defaultText = string.format(text.."%d",index)
- self.ui.Items[defaultText]:setTextColor(SELECT_COLOR)
- end
-
- local result = self.WanFaCheckBoxManager:getResult2()
- if result.baojiao == 1 then
- self.ui.Items.Text_BaoJiao:setTextColor(SELECT_COLOR)
- end
- end
-
- --点击checkBox时,改变其text的颜色
- function MJCreateRoomItem:updataTextColor(radio,text,boxType,valueTab)
- local function updataRadioTextColor()
- if boxType == "radioBox" then
- local index = radio:getResult()
- for k,value in pairs(valueTab) do
- local item = string.format(text.."%d",value)
- self.ui.Items[item]:setTextColor(NON_SELECT_COLOR)
- if value == index then
- self.ui.Items[item]:setTextColor(SELECT_COLOR)
- end
- end
- elseif boxType == "checkBox" then
- local result = self.WanFaCheckBoxManager:getResult2()
- if result.baojiao == 1 then
- self.ui.Items.Text_BaoJiao:setTextColor(SELECT_COLOR)
- else
- self.ui.Items.Text_BaoJiao:setTextColor(NON_SELECT_COLOR)
- end
- end
- end
-
- radio:setCallback(updataRadioTextColor);
- end
-
- function MJCreateRoomItem:getRuleResult()
- local game_num = self.JuShuRadioManager:getResult()
- local payMode = self.PayRadioManager:getResult()
- local playnum = self.PlayerNumRadioManager:getResult();
- local isfaststart = (playnum == 0) and 1 or 0;
- playnum = (playnum == 0) and 4 or playnum;
-
- local duogang = self.DuoTouRadioManager:getResult();
- local piaomode = self.PiaoRadioManager:getResult();
- local limitfan = self.FengDingRadioManager:getResult();
-
- local dianganghua = self.DianGangHuaRadioManager:getResult();
- local specialRule = 0;
- specialRule = getNumOr(specialRule, dianganghua);
-
- local wanfaResult = self.WanFaCheckBoxManager:getResult2();
- for k, v in pairs(wanfaResult or {}) do
- if k ~= "chaojiluobo" and k~= "chajiao" and v > 0 then
- specialRule = getNumOr(specialRule, v);
- end
- end
-
- if wanfaResult["huluobo"] > 0 then
- specialRule = getNumOr(specialRule, wanfaResult["chaojiluobo"]);
- end
-
- --换三张
- local hszResult = self.HuanSanZhangRadioManager:getResult();
- specialRule = getNumOr(specialRule, hszResult);
-
- --起始萝卜
- local luoboResult = self.LuoBoRadioManager:getResult();
- specialRule = getNumOr(specialRule, luoboResult);
-
- --七对全胡
- local qidui = self.QiDuiRadioManager:getResult()
- qidui = playnum == 2 and 0 or qidui
-
- --四人胡完
- local sirenhuwanResult = self.SiRenHuWanCheckBoxManager:getResult2();
- if playnum == 4 or isfaststart == 1 then
- specialRule = getNumOr(specialRule, sirenhuwanResult["sirenhuwan"]);
- end
-
- local tianhuquanhuResult = self.TianHuQuanHuCheckBoxManager:getResult2();
- if playnum ~= 2 then
- --天胡全胡
- specialRule = getNumOr(specialRule, tianhuquanhuResult["tianhuquanhu"]);
- end
-
- --神龙
- local shenlong = self.ShenLongRadioManager:getResult()
-
- local chajiao = wanfaResult["chajiao"];
-
- local other = self.otherCheckBoxManager:getResult2()
- local forbidProp = other["forbidProp"]
- local forbidVoice = other["forbidVoice"]
-
- self.defaultValus = {
- gamerule = 2,
- QiDuiQuanHu = qidui,
- ShenLong = shenlong,
- totalgamenum = game_num,
- deductRule = payMode,
- playnum = playnum,
- isfaststart = isfaststart,
- limitfan = limitfan,
- piaomode = piaomode,
- duogang = duogang,
- specRule = specialRule,
- chajiao = chajiao,
- forbidProp = forbidProp,
- forbidVoice = forbidVoice,
-
- tingpai = 1,
- baseMulti = self.curJFBS,
- };
-
- -- 保存玩家的选择
- self:saveDefaultValues()
-
- local strGameInfo = json.encode(self.defaultValus);
- return game_num, strGameInfo
- end
-
-
- return MJCreateRoomItem
|