fix: onitama win con
This commit is contained in:
@@ -266,10 +266,10 @@ describe('Onitama Game', () => {
|
||||
});
|
||||
|
||||
describe('Win Conditions', () => {
|
||||
it('should detect conquest win for red (master reaches y=4)', async () => {
|
||||
it('should detect conquest win for red (master reaches 2,4)', async () => {
|
||||
const { ctx } = createDeterministicContext();
|
||||
|
||||
// Move red master to y=4
|
||||
// Move red master to (2, 4) - black master's initial position
|
||||
ctx.produce(state => {
|
||||
const redMaster = state.pawns['red-master'];
|
||||
redMaster.position = [2, 4];
|
||||
@@ -282,10 +282,10 @@ describe('Onitama Game', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should detect conquest win for black (master reaches y=0)', async () => {
|
||||
it('should detect conquest win for black (master reaches 2,0)', async () => {
|
||||
const { ctx } = createDeterministicContext();
|
||||
|
||||
// Move black master to y=0
|
||||
// Move black master to (2, 0) - red master's initial position
|
||||
ctx.produce(state => {
|
||||
const blackMaster = state.pawns['black-master'];
|
||||
blackMaster.position = [2, 0];
|
||||
@@ -298,6 +298,38 @@ describe('Onitama Game', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should NOT detect conquest win for red if x is wrong', async () => {
|
||||
const { ctx } = createDeterministicContext();
|
||||
|
||||
// Move red master to (1, 4) - wrong x position
|
||||
ctx.produce(state => {
|
||||
const redMaster = state.pawns['red-master'];
|
||||
redMaster.position = [1, 4];
|
||||
});
|
||||
|
||||
const result = await ctx.run('check-win');
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.result).toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
it('should NOT detect conquest win for black if x is wrong', async () => {
|
||||
const { ctx } = createDeterministicContext();
|
||||
|
||||
// Move black master to (3, 0) - wrong x position
|
||||
ctx.produce(state => {
|
||||
const blackMaster = state.pawns['black-master'];
|
||||
blackMaster.position = [3, 0];
|
||||
});
|
||||
|
||||
const result = await ctx.run('check-win');
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.result).toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
it('should detect capture win when red master is captured', async () => {
|
||||
const { ctx } = createDeterministicContext();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user