| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- var RulesKey = window.QPName + '_Rules_';
- var RulesKey2 = window.QPName + '_S_Rules_';
- cc.Class({
- //extends: cc.BaseClass,
- extends: cc.SubRoomRules,
- properties: {
- // m_LabBaseScore: cc.Label,
- // m_LabRevenue: cc.Label,
- // m_ClubNode: cc.Node,
- // m_EbBaseScore: cc.EditBox,
- // m_BtNNSet: cc.Button, //牛牛设置按钮
- // m_togSpecialType: [cc.Toggle], //牛牛特殊牌型
- },
- //1000-1031 服务器规则 1050-1099 对应规则
- //1000 =>AA付 1050 =>房主付
- //1001 =>代开 1051 =>房主进入
- //1002 =>积分房间 1003 =>金币房间 1052 =>练习房间
- ctor: function () {
- this.m_bNeedUpdate = false;
- this.m_bFirstShow = true;
- // //对立规则 非计算索引需 大于 32
- // this.m_CheckMap = new Object();
- // this.m_CheckMap[10011] = new Array(
- // // [12,33],
- // );
- // this.m_CheckMap[60013] = new Array(
- // [6, 33], // 3息1囤 3息1分 / 1息1分
- // [7, 34], // 底牌 留底19张 / 留底39张
- // );
- // this.m_CheckMap2 = new Array(
- // [1000, 1050],
- // [1001, 1051],
- // [1002, 1052],
- // [1003, 1052],
- // );
- // this.m_BaseScore = 1;
- // this.m_SitScore = 100;
- // this.m_Revenue = 0;
- },
- //添加对立规则数组索引
- CheckToggle(ArrIndex, JS) {
- // for (var i in this.m_CheckMap) {
- // for (var j in this.m_CheckMap[i]) {
- // if (JS.node.name == this.m_CheckMap[i][j][1]) this.m_CheckMap[i][j][2] = ArrIndex;
- // }
- // }
- // for (var i in this.m_CheckMap2) {
- // if (JS.node.name == this.m_CheckMap2[i][1]) this.m_CheckMap2[i][2] = ArrIndex;
- // }
- },
- OnShowView: function () {
- // //初始化数据
- // if (this.m_togArr == null) {
- // this.m_togArr = this.node.getComponentsInChildren(cc.Toggle);
- // for (var i in this.m_togArr) {
- // this.CheckToggle(i, this.m_togArr[i]);
- // }
- // }
- this.m_bNeedUpdate = true;
- // this.m_bFirstShow = false;
- // var rules = JSON.parse(cc.sys.localStorage.getItem(RulesKey + this.m_KindID));
- // var rules2 = cc.sys.localStorage.getItem(RulesKey2 + this.m_KindID);
- // if (rules != null) {
- // for (var i in this.m_togArr) {
- // var rulesIndex = parseInt(this.m_togArr[i].node.name);
- // var rIndex = parseInt(rulesIndex / 100);
- // var rValue = parseInt(rulesIndex % 100);
- // if (rIndex >= 3) continue; //3底分 4抽水
- // if (rValue < 32) {
- // //游戏规则
- // if (rules[rIndex] & (1 << rValue)) {
- // this.m_togArr[i].check();
- // } else {
- // if (this.m_togArr[i].toggleGroup == null || this.m_togArr[i].toggleGroup.allowSwitchOff) { //复选框
- // this.m_togArr[i].isChecked = false;
- // } else if (this.m_CheckMap[this.m_KindID] != null) { //对立规则勾选
- // for (var j in this.m_CheckMap[this.m_KindID]) {
- // if (this.m_CheckMap[this.m_KindID][j][0] == rValue) {
- // this.m_togArr[this.m_CheckMap[this.m_KindID][j][2]].check();
- // }
- // }
- // }
- // }
- // }
- // }
- // }
- // if (rules == null) rules = [0, 0, 0, 0, 0];
- // //2底分 3入场分 4抽水
- // this.m_BaseScore = rules[2];
- // if (this.m_BaseScore == null || this.m_BaseScore == 0) this.m_BaseScore = 1;
- // if (this.m_EbBaseScore != null) this.m_EbBaseScore.string = this.m_BaseScore;
- // this.m_SitScore = rules[3];
- // if (this.m_SitScore == null || this.m_SitScore == 0) this.m_SitScore = 100;
- // this.m_Revenue = rules[4];
- // if (this.m_Revenue == null) this.m_Revenue = 0;
- // this.UpdateBaseScore();
- // this.UpdateRevenue();
- return;
- var rules = cc.sys.localStorage.getItem(RulesKey + this.m_KindID);
- var rules2 = cc.sys.localStorage.getItem(RulesKey2 + this.m_KindID);
- //还原选项
- for (var i in this.m_togArr) {
- if (rules == null || !this.m_bFirstShow) break;
- var rulesIndex = parseInt(this.m_togArr[i].node.name);
- if (rulesIndex < 32) {
- //游戏规则
- if (rules & (1 << rulesIndex)) {
- this.m_togArr[i].check();
- } else {
- if (this.m_togArr[i].toggleGroup == null || this.m_togArr[i].toggleGroup.allowSwitchOff) { //复选框
- this.m_togArr[i].isChecked = false;
- } else if (this.m_CheckMap[this.m_KindID] != null) { //对立规则勾选
- for (var j in this.m_CheckMap[this.m_KindID]) {
- if (this.m_CheckMap[this.m_KindID][j][0] == rulesIndex) {
- this.m_togArr[this.m_CheckMap[this.m_KindID][j][2]].check();
- }
- }
- }
- }
- } else if (rulesIndex >= 100 && rulesIndex < 150) {
- //服务器规则
- if (rules2 & (1 << (rulesIndex - 100))) {
- this.m_togArr[i].check();
- } else {
- if (this.m_togArr[i].toggleGroup == null || this.m_togArr[i].toggleGroup.allowSwitchOff) { //复选框
- this.m_togArr[i].isChecked = false;
- } else { //对立规则勾选
- for (var j in this.m_CheckMap2) {
- if (this.m_CheckMap2[j][0] == rulesIndex) {
- this.m_togArr[this.m_CheckMap2[j][2]].check();
- }
- }
- }
- }
- }
- }
- this.m_bNeedUpdate = true;
- this.m_bFirstShow = false;
- },
- OnHideView: function () {
- this.getRulesEx();
- this.getServerRules();
- this.node.active = false;
- },
- SetClubView: function (RoomType) {
- //this.$('ClubNode').active = RoomType == 1;
- if (this.m_ClubNode != null) this.m_ClubNode.active = (RoomType != 0);
- this.m_bNeedUpdate = true;
- },
- OnToggleClick: function (Tag, Data) {
- this.m_bNeedUpdate = true;
- },
- // getRulesEx: function (bLog) {
- // var rules = [0, 0, 0, 0, 0];
- // for (var i in this.m_togArr) {
- // if (this.m_togArr[i].node.active && this.m_togArr[i].isChecked) {
- // var rulesIndex = parseInt(this.m_togArr[i].node.name);
- // if (bLog && window.LOG_NET_DATA) console.log(rulesIndex + ' ==> ' + this.$('Label@Label', this.m_togArr[i].node).string);
- // // if (rulesIndex >= 1000) {
- // // if (rulesIndex <= 1031) rules[5] += 1 << (rulesIndex - 1000);
- // // } else
- // {
- // var rIndex = parseInt(rulesIndex / 100);
- // var rValue = parseInt(rulesIndex % 100);
- // if (rIndex >= 3) continue; //3底分 4抽水
- // if (rValue <= 31) rules[rIndex] += 1 << rValue;
- // }
- // }
- // }
- // if (this.m_EbBaseScore != null) {
- // rules[2] = parseInt(this.m_EbBaseScore.string);
- // } else {
- // rules[2] = 1;
- // }
- // rules[3] = this.m_SitScore;
- // rules[4] = this.m_Revenue;
- // // if(this.$('ClubNode').active){
- // // rules[2] = parseInt(this.$('ClubNode/EnterGame/116/Background/BG/EditBox@EditBox').string);
- // // rules[3] = parseInt(this.$('ClubNode/EnterGame/117/Background/BG/EditBox@EditBox').string);
- // // rules[4] = parseInt(this.$('ClubNode/EnterGame/118/Background/BG/EditBox@EditBox').string);
- // // if(rules[2] > 0) {} else {rules[2] = 0};
- // // if(rules[3] > 0) {} else {rules[3] = 0};
- // // if(rules[4] > 0) {} else {rules[4] = 0};
- // // }
- // cc.sys.localStorage.setItem(RulesKey + this.m_KindID, JSON.stringify(rules));
- // return rules;
- // },
- // getRules: function (bLog) {
- // var rules = 0;
- // for (var i in this.m_togArr) {
- // if (this.m_togArr[i].node.active && this.m_togArr[i].isChecked) {
- // var rulesIndex = parseInt(this.m_togArr[i].node.name);
- // if (bLog && window.LOG_NET_DATA) console.log(rulesIndex + ' ==> ' + this.$('Label@Label', this.m_togArr[i].node).string);
- // if (rulesIndex <= 32) rules += 1 << rulesIndex;
- // }
- // }
- // cc.sys.localStorage.setItem(RulesKey + this.m_KindID, rules);
- // return rules;
- // },
- // getServerRules: function () {
- // var rules = 0;
- // for (var i in this.m_togArr) {
- // if (this.m_togArr[i].node.active && this.m_togArr[i].isChecked) {
- // var rulesIndex = parseInt(this.m_togArr[i].node.name);
- // if (rulesIndex < 1000 || rulesIndex >= 1050) continue;
- // rulesIndex -= 1000;
- // rules += 1 << rulesIndex;
- // }
- // }
- // cc.sys.localStorage.setItem(RulesKey2 + this.m_KindID, rules);
- // return rules;
- // },
- // update: function () {
- // if (this.m_bNeedUpdate) {
- // this.m_bNeedUpdate = false;
- // } else {
- // return;
- // }
- // for (var i in this.m_togArr) {
- // if (!this.m_togArr[i].node.active) continue;
- // var color = this.m_togArr[i].isChecked ? cc.color(182, 153, 95) : cc.color(143, 195, 203);
- // this.m_togArr[i].node.getChildByName('Label').color = color;
- // }
- // this.OnCheckHZMJ();
-
- // },
-
- OnUpdateCustomView:function()
- {
- this.GetPayWay();
- this.OnChecTWMJ();
- for (var i in this.m_togArr) {
- if (!this.m_togArr[i].node.active) continue;
- var color = this.m_togArr[i].isChecked ? cc.color(208,185,239) : cc.color(129,95,57);
- this.m_togArr[i].node.getChildByName('Label').color = color;
- }
- },
- // //底分加
- // OnBtBaseScoreAdd: function () {
- // if (this.m_LabBaseScore != null) {
- // if (this.m_SitScore < 1000) {
- // cc.gSoundRes.PlaySound('Button');
- // this.m_SitScore = this.m_SitScore + 100;
- // this.UpdateBaseScore();
- // }
- // }
- // },
- // //底分减
- // OnBtBaseScoreReduce: function () {
- // if (this.m_LabBaseScore != null) {
- // if (this.m_SitScore > 100) {
- // cc.gSoundRes.PlaySound('Button');
- // this.m_SitScore = this.m_SitScore - 100;
- // this.UpdateBaseScore();
- // }
- // }
- // },
- UpdateBaseScore: function () {
- if (this.m_LabBaseScore != null) this.m_LabBaseScore.string = this.m_SitScore;
- },
- // //抽水加
- // OnBtRevenueAdd: function () {
- // if (this.m_LabRevenue != null) {
- // if (this.m_Revenue < 10) {
- // cc.gSoundRes.PlaySound('Button');
- // this.m_Revenue = this.m_Revenue + 1;
- // this.UpdateRevenue();
- // }
- // }
- // },
- // //抽水减
- // OnBtRevenueReduce: function () {
- // if (this.m_LabRevenue != null) {
- // if (this.m_Revenue > 0) {
- // cc.gSoundRes.PlaySound('Button');
- // this.m_Revenue = this.m_Revenue - 1;
- // this.UpdateRevenue();
- // }
- // }
- // },
- // UpdateRevenue: function () {
- // if (this.m_LabRevenue != null) this.m_LabRevenue.string = this.m_Revenue + '%';
- // },
- //台湾麻将
- OnChecTWMJ: function () {
- // var RuleHZ;
- // var RuleHZ1, RuleHZ2, RuleHZ3;
- // for (var i in this.m_togArr) {
- // if (this.m_togArr[i].node.name == 10) RuleHZ = i;
- // if (this.m_togArr[i].node.name == 23) RuleHZ1 = i;
- // if (this.m_togArr[i].node.name == 24) RuleHZ2 = i;
- // if (this.m_togArr[i].node.name == 25) RuleHZ3 = i;
- // }
- // if (this.m_togArr[RuleHZ].isChecked)//台湾北部麻将玩法
- // {
- // this.m_togArr[RuleHZ1].interactable = true;
- // this.m_togArr[RuleHZ2].interactable = true;
- // this.m_togArr[RuleHZ3].interactable = true;
- // } else {
- // this.m_togArr[RuleHZ1].isChecked = false;
- // this.m_togArr[RuleHZ2].isChecked = false;
- // this.m_togArr[RuleHZ3].isChecked = false;
- // this.m_togArr[RuleHZ1].interactable = false;
- // this.m_togArr[RuleHZ2].interactable = false;
- // this.m_togArr[RuleHZ3].interactable = false;
- // }
- var RuleBB,RuleNB;
- var RuleBB1,RuleNB1;
- for (var i in this.m_togArr) {
- if (this.m_togArr[i].node.name == 26) RuleBB = i; //台湾北部麻将玩法
- if (this.m_togArr[i].node.name == 27) RuleNB = i; //台湾南部麻将玩法
- if (this.m_togArr[i].node.name == 28) RuleBB1 = i; //台湾北部呖咕呖咕 玩法
- // if (this.m_togArr[i].node.name == 9) RuleNB1 = i; //台湾南部庄家无台 玩法
- }
-
- // if (this.m_togArr[RuleNB].isChecked)
- // {
- // this.m_togArr[RuleBB1].node.active = false;
- // this.m_togArr[RuleNB1].node.active = true;
- // this.m_togArr[RuleBB1].isChecked = false;
- // } else if(this.m_togArr[RuleBB].isChecked) {
- // this.m_togArr[RuleNB1].isChecked = false;
- // this.m_togArr[RuleBB1].node.active = true;
- // this.m_togArr[RuleNB1].node.active = false;
- // }
- let isShowNorth = this.m_togArr[RuleBB].isChecked;
- this.m_togArr[RuleBB1].node.parent.active = isShowNorth;
-
- },
- // GetPayWay:function(){
- // var renshu2,renshu3,renshu4;
- // var Path = "ScrollView/view/content/";
- // for (var i in this.m_togArr) {
- // if (this.m_togArr[i].node.name == 1018) renshu2 =i;
- // if (this.m_togArr[i].node.name == 1017) renshu3 =i;
- // if (this.m_togArr[i].node.name == 1016) renshu4 =i;
- // }
- // if(this.m_togArr[renshu2].isChecked&&this.$(Path + "PayWay/1050@Toggle").isChecked){
-
- // this.$(Path + "GameCount/1019/Label@Label").string = '8局X4';
- // this.$(Path + "GameCount/1020/Label@Label").string = '12局X6';
- // this.$(Path + "GameCount/1021/Label@Label").string = '16局X8';
- // }
-
- // if(this.m_togArr[renshu3].isChecked&&this.$(Path + "PayWay/1050@Toggle").isChecked){
-
- // this.$(Path + "GameCount/1019/Label@Label").string = '8局X6';
- // this.$(Path + "GameCount/1020/Label@Label").string = '12局X9';
- // this.$(Path + "GameCount/1021/Label@Label").string = '16局X12';
- // }
-
- // if(this.m_togArr[renshu4].isChecked&&this.$(Path + "PayWay/1050@Toggle").isChecked){
-
- // this.$(Path + "GameCount/1019/Label@Label").string = '8局X8';
- // this.$(Path + "GameCount/1020/Label@Label").string = '12局X12';
- // this.$(Path + "GameCount/1021/Label@Label").string = '16局X16';
- // }
- // if(this.$(Path + "PayWay/1000@Toggle").isChecked){
-
- // this.$(Path + "GameCount/1019/Label@Label").string = '8局x2';
- // this.$(Path + "GameCount/1020/Label@Label").string = '12局x3';
- // this.$(Path + "GameCount/1021/Label@Label").string = '16局x4';
- // }
-
-
-
- // },
- GetPayWay: function () {
- var payWayPath = "PayWay/1050@Toggle";
- var gameCountPath = "GameCount/";
- var labels = [
- { node: '1019/Label@Label', text: ['8局X4', '8局X6', '8局X8'] },
- { node: '1020/Label@Label', text: ['12局X6', '12局X9', '12局X12'] },
- { node: '1021/Label@Label', text: ['16局X8', '16局X12', '16局X16'] }
- ];
- var alternativeLabels = ['8局x2', '12局x3', '16局x4'];
- var renshuIndices = { 1018: null, 1017: null, 1016: null };
- var Path = "ScrollView/view/content/";
-
- for (var i in this.m_togArr) {
- var nodeName = this.m_togArr[i].node.name;
- if (renshuIndices.hasOwnProperty(nodeName)) {
- renshuIndices[nodeName] = i;
- }
- }
-
- var setLabels = function (labelArray, checkedIndex) {
- for (var j in labelArray) {
- this.$(Path + gameCountPath + labelArray[j].node).string = labelArray[j].text[checkedIndex];
- }
- }.bind(this);
-
- if (this.$(Path + payWayPath).isChecked) {
- if (renshuIndices[1018] !== null && this.m_togArr[renshuIndices[1018]].isChecked) {
- setLabels(labels, 0);
- } else if (renshuIndices[1017] !== null && this.m_togArr[renshuIndices[1017]].isChecked) {
- setLabels(labels, 1);
- } else if (renshuIndices[1016] !== null && this.m_togArr[renshuIndices[1016]].isChecked) {
- setLabels(labels, 2);
- }
- }
-
- var alternativePayWayPath = "PayWay/1000@Toggle";
- if (this.$(Path + alternativePayWayPath).isChecked) {
- for (var k in alternativeLabels) {
- this.$(Path + gameCountPath + labels[k].node).string = alternativeLabels[k];
- }
- }
- },
- });
|