Files
erqiwang_youle/client/js/01_SubGame/codes/state/RoomOptions.js
T
joywayerandClaude Opus 5 a82969a23b 二七王:前端 roomtype 位串解析
与服务端 class.config.js 的 parse() 同规则;缺失/非字符串/过短一律按 '0',
这是协议 §0.5 明文规定的行为。已逐位对照服务端确认。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 17:21:39 +08:00

35 lines
1.4 KiB
JavaScript

///////////////////////////////////////////////////////////////
////////// 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)
};
}
};
})();