二七王:前端 SeatMap,服务端座位与显示位互换
清单 §0.1:下家 (seat+1)%3 显示在右上,与服务端 get_nextseat 同源。 3×3 全组合 + 互逆 + 非法键抛错都已覆盖。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
////////// EQW_SeatMap: 服务端座位 ↔ 屏幕显示位(纯逻辑)///////
|
||||
///////////////////////////////////////////////////////////////
|
||||
// 清单 §0.1:服务端座位是绝对序号 0/1/2;前端一律把自己放底部,
|
||||
// 另两家按 design §4 的逆时针顺序分居左上、右上。
|
||||
// 底部(自己) = mySeat
|
||||
// 右上(下家) = (mySeat + 1) % 3 ← 服务端 class.paiju.js:264 get_nextseat
|
||||
// 左上(上家) = (mySeat + 2) % 3
|
||||
// 【全前端只此一处实现】布局配置的 bySeat 键、各界面的座位换算都用它。
|
||||
var EQW_SeatMap = EQW_SeatMap || {
|
||||
|
||||
SELF: 'SELF',
|
||||
LEFT: 'LEFT',
|
||||
RIGHT: 'RIGHT',
|
||||
|
||||
//服务端座位 → 显示位键
|
||||
toDisplay: function (seat, mySeat) {
|
||||
var d = ((seat - mySeat) % 3 + 3) % 3;
|
||||
if (d === 0) { return 'SELF'; }
|
||||
if (d === 1) { return 'RIGHT'; }
|
||||
return 'LEFT';
|
||||
},
|
||||
|
||||
//显示位键 → 服务端座位
|
||||
toSeat: function (displayKey, mySeat) {
|
||||
if (displayKey === 'SELF') { return mySeat; }
|
||||
if (displayKey === 'RIGHT') { return (mySeat + 1) % 3; }
|
||||
if (displayKey === 'LEFT') { return (mySeat + 2) % 3; }
|
||||
throw new Error('[EQW_SeatMap] 未知显示位: ' + displayKey);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user