feat(framework): core 座位↔视图转换
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { toView, fromView } from '../../YouleNexus/assets/framework/core/seat.ts';
|
||||
|
||||
test('toView:自己永远是视图 0 号位', () => {
|
||||
assert.equal(toView(2, 2, 4), 0); // mySeat=2, target=2 → 0
|
||||
});
|
||||
|
||||
test('toView:他人按环形相对自己排布', () => {
|
||||
// 4 人桌,我在 2 号位:座位 3→视图1,座位 0→视图2,座位 1→视图3
|
||||
assert.equal(toView(2, 3, 4), 1);
|
||||
assert.equal(toView(2, 0, 4), 2);
|
||||
assert.equal(toView(2, 1, 4), 3);
|
||||
});
|
||||
|
||||
test('fromView 是 toView 的逆运算', () => {
|
||||
const seatCount = 4, mySeat = 2;
|
||||
for (let s = 0; s < seatCount; s++) {
|
||||
assert.equal(fromView(mySeat, toView(mySeat, s, seatCount), seatCount), s);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user