/////////////////////////////////////////////////////////////// ////////// EQW_RoomOptions_Parse: roomtype 位串解析 /////////// /////////////////////////////////////////////////////////////// // 协议 §0.5:roomtype 是建房时拼好的定长数字位串(字符串),每一位 '0'/'1'。 // 服务端解析入口是 class.config.js 的 parse(),本文件必须与之【同规则】。 // // 位0 局数 '0'=6局(缺省) '1'=12局 // 位1 扣卡 '0'=房主扣卡 '1'=AA 每人扣卡 // 位2 傍王 '0'=关 '1'=开 // 位3 爬坡 '0'=常规算子 '1'=爬坡 // 位4 查牌 '0'=可查牌 '1'=不查牌 // // 对【缺失、非字符串、过短】的 roomtype 一律按 '0' 处理(与服务端一致), // 这是协议明文规定的行为,不是隐式兜底。 var EQW_RoomOptions_Parse = (function() { //取第 idx 位,越界或非字符串时按 '0' function _bit(roomtype, idx) { if (typeof roomtype !== 'string') { return 0; } if (idx >= roomtype.length) { return 0; } return roomtype.charAt(idx) === '1' ? 1 : 0; } return { parse: function (roomtype) { return { asetCount: _bit(roomtype, 0) ? 12 : 6, deductAA: _bit(roomtype, 1), bangwang: _bit(roomtype, 2), climb: _bit(roomtype, 3), nocheck: _bit(roomtype, 4) }; } }; })();